Details Lerngruppe, Archiv, Stub Import
This commit is contained in:
@@ -16,6 +16,7 @@ public class LiteDbContext : IDisposable
|
||||
{
|
||||
Connection = ConnectionType.Shared,
|
||||
});
|
||||
MigrateExistingData();
|
||||
EnsureIndexes();
|
||||
}
|
||||
|
||||
@@ -38,11 +39,25 @@ public class LiteDbContext : IDisposable
|
||||
|
||||
public void Checkpoint() => _db.Checkpoint();
|
||||
|
||||
private void MigrateExistingData()
|
||||
{
|
||||
var groups = _db.GetCollection<BsonDocument>("groups");
|
||||
var missingArchiveState = groups.FindAll()
|
||||
.Where(g => !g.ContainsKey(nameof(LearningGroup.IsActive)))
|
||||
.ToList();
|
||||
foreach (var group in missingArchiveState)
|
||||
{
|
||||
group[nameof(LearningGroup.IsActive)] = true;
|
||||
groups.Update(group);
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureIndexes()
|
||||
{
|
||||
Students.EnsureIndex(x => x.LastName);
|
||||
Students.EnsureIndex(x => x.IsActive);
|
||||
Groups.EnsureIndex(x => x.SchoolYear);
|
||||
Groups.EnsureIndex(x => x.IsActive);
|
||||
Enrollments.EnsureIndex(x => x.StudentId);
|
||||
Enrollments.EnsureIndex(x => x.GroupId);
|
||||
Enrollments.EnsureIndex(x => x.SchoolYear);
|
||||
|
||||
Reference in New Issue
Block a user