mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using LiteDB;
|
|
|
|
namespace Artemis.Storage.Migrator.Legacy.Migrations.Storage;
|
|
|
|
public class M0023LayoutProviders : IStorageMigration
|
|
{
|
|
public int UserVersion => 23;
|
|
|
|
public void Apply(LiteRepository repository)
|
|
{
|
|
ILiteCollection<BsonDocument> deviceEntities = repository.Database.GetCollection("DeviceEntity");
|
|
List<BsonDocument> toUpdate = new();
|
|
|
|
foreach (BsonDocument bsonDocument in deviceEntities.FindAll())
|
|
{
|
|
if (bsonDocument.TryGetValue("CustomLayoutPath", out BsonValue customLayoutPath) && customLayoutPath.IsString && !string.IsNullOrEmpty(customLayoutPath.AsString))
|
|
{
|
|
bsonDocument.Add("LayoutType", new BsonValue("CustomPath"));
|
|
bsonDocument.Add("LayoutParameter", new BsonValue(customLayoutPath.AsString));
|
|
}
|
|
else if (bsonDocument.TryGetValue("DisableDefaultLayout", out BsonValue disableDefaultLayout) && disableDefaultLayout.AsBoolean)
|
|
bsonDocument.Add("LayoutType", new BsonValue("None"));
|
|
else
|
|
bsonDocument.Add("LayoutType", new BsonValue("Default"));
|
|
|
|
bsonDocument.Remove("CustomLayoutPath");
|
|
bsonDocument.Remove("DisableDefaultLayout");
|
|
toUpdate.Add(bsonDocument);
|
|
}
|
|
|
|
deviceEntities.Update(toUpdate);
|
|
}
|
|
} |