mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Core - Moved first run code to the static utility class
Core - Improved first run code, this closes #504 Storage - Fixed some migrations on fresh databases
This commit is contained in:
1 parent
0c7583d3e4
commit
9e75131948
10 files changed
+124
-50
No files matched your search
@@ -9,6 +9,8 @@ namespace Artemis.Storage.Migrations
|
||||
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
// DropCollection will open a transaction so commit the current one
|
||||
repository.Database.Commit();
|
||||
if (repository.Database.CollectionExists("ProfileEntity"))
|
||||
repository.Database.DropCollection("ProfileEntity");
|
||||
}
|
||||
|
||||
@@ -6,9 +6,11 @@ namespace Artemis.Storage.Migrations
|
||||
public class M3PluginEntitiesIndexChangesMigration : IStorageMigration
|
||||
{
|
||||
public int UserVersion => 3;
|
||||
|
||||
|
||||
public void Apply(LiteRepository repository)
|
||||
{
|
||||
// DropCollection will open a transaction so commit the current one
|
||||
repository.Database.Commit();
|
||||
if (repository.Database.CollectionExists("PluginEntity"))
|
||||
repository.Database.DropCollection("PluginEntity");
|
||||
if (repository.Database.CollectionExists("PluginSettingEntity"))
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Storage.Migrations.Interfaces;
|
||||
using LiteDB;
|
||||
@@ -32,9 +33,17 @@ namespace Artemis.Storage
|
||||
storageMigration.GetType().Name, _repository.Database.UserVersion, storageMigration.UserVersion);
|
||||
|
||||
_repository.Database.BeginTrans();
|
||||
storageMigration.Apply(_repository);
|
||||
try
|
||||
{
|
||||
storageMigration.Apply(_repository);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_repository.Database.Rollback();
|
||||
throw;
|
||||
}
|
||||
_repository.Database.Commit();
|
||||
|
||||
|
||||
_repository.Database.UserVersion = storageMigration.UserVersion;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user