2022-11-06 20:07:41 +00:00
|
|
|
|
using DataModel.Database.Common;
|
|
|
|
|
|
|
|
|
|
namespace DataModel.MigrationScripts;
|
|
|
|
|
|
|
|
|
|
public static class Script202211AddUniqueIds
|
|
|
|
|
{
|
|
|
|
|
public static async Task PostMigrationAsync(DataContext db)
|
|
|
|
|
{
|
|
|
|
|
await foreach (var setting in db.Settings)
|
2023-02-11 20:22:25 +00:00
|
|
|
|
{
|
|
|
|
|
if(setting.UniqueId == Guid.Empty)
|
|
|
|
|
setting.UniqueId = Guid.NewGuid();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 20:07:41 +00:00
|
|
|
|
await foreach(var section in db.Sections)
|
2023-02-11 20:22:25 +00:00
|
|
|
|
{
|
|
|
|
|
if(section.UniqueId == Guid.Empty)
|
|
|
|
|
section.UniqueId = Guid.NewGuid();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 20:07:41 +00:00
|
|
|
|
await foreach (var textElement in db.TextElements)
|
2023-02-11 20:22:25 +00:00
|
|
|
|
{
|
|
|
|
|
if(textElement.UniqueId == Guid.Empty)
|
|
|
|
|
textElement.UniqueId = Guid.NewGuid();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-06 20:07:41 +00:00
|
|
|
|
await foreach (var translation in db.Translations)
|
2023-02-11 20:22:25 +00:00
|
|
|
|
{
|
|
|
|
|
if(translation.UniqueId == Guid.Empty)
|
|
|
|
|
translation.UniqueId = Guid.NewGuid();
|
|
|
|
|
}
|
2022-11-06 20:07:41 +00:00
|
|
|
|
|
|
|
|
|
await db.SaveChangesAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|