-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement migration downgrade with data loss
- Loading branch information
1 parent
6b8d2e5
commit 2ab2124
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,13 +127,93 @@ public async Task TestUpgrade() | |
[Fact] | ||
public async Task TestDowngrade() | ||
{ | ||
|
||
PersonFilterTree.Status status = new() | ||
{ | ||
Id = 1, | ||
Name = "unknown", | ||
}; | ||
PersonFilterTree.GroupStatus groupStatus = new() | ||
{ | ||
Id = 1, | ||
Name = "active", | ||
}; | ||
PersonFilterTree.GroupType groupType = new() | ||
{ | ||
Id = 1, | ||
Name = "Kleingruppe", | ||
}; | ||
PersonFilterTree.Group group = new() | ||
{ | ||
Id = 1, | ||
Name = "Hauskreis", | ||
GroupTypeId = 1, | ||
GroupStatusId = 1, | ||
}; | ||
PersonFilterTree.Person person = new() | ||
{ | ||
Id = 1, | ||
StatusId = 1, | ||
FirstName = "Max", | ||
LastName = "Mustermann", | ||
Email = "[email protected]", | ||
}; | ||
PersonFilterTree.StatusFilter statusFilter = new() | ||
{ | ||
Id = 1, | ||
StatusId = 1, | ||
}; | ||
PersonFilterTree.DistributionList distToStatus = new() | ||
{ | ||
Id = 1, | ||
Alias = "unknown", | ||
PermittedRecipientsId = 1, | ||
}; | ||
PersonFilterTree.DistributionList distToNobody = new() | ||
{ | ||
Id = 2, | ||
Alias = "nobody", | ||
PermittedRecipientsId = null, | ||
}; | ||
PersonFilterTree.GroupFilter groupFilter = new() | ||
{ | ||
Id = 2, | ||
ParentId = 4, | ||
GroupId = 1, | ||
}; | ||
PersonFilterTree.SinglePerson singlePerson = new() | ||
{ | ||
Id = 3, | ||
ParentId = 4, | ||
PersonId = 1, | ||
}; | ||
PersonFilterTree.LogicalOr groupOrPerson = new() | ||
{ | ||
Id = 4, | ||
}; | ||
PersonFilterTree.DistributionList distToGroupAndSinglePerson = new() | ||
{ | ||
Id = 3, | ||
Alias = "kleingruppen", | ||
PermittedRecipientsId = 4, | ||
}; | ||
IMigrator migrator = databaseContext.GetInfrastructure().GetRequiredService<IMigrator>(); | ||
|
||
// Create database schema of the migration to test | ||
await migrator.MigrateAsync("PersonFilterTree"); | ||
|
||
// Add test data | ||
after.Status.Add(status); | ||
after.GroupStatuses.Add(groupStatus); | ||
after.GroupTypes.Add(groupType); | ||
after.Groups.Add(group); | ||
after.People.Add(person); | ||
after.PersonFilters.Add(statusFilter); | ||
after.DistributionLists.Add(distToStatus); | ||
after.DistributionLists.Add(distToNobody); | ||
after.PersonFilters.Add(groupFilter); | ||
after.PersonFilters.Add(singlePerson); | ||
after.PersonFilters.Add(groupOrPerson); | ||
after.DistributionLists.Add(distToGroupAndSinglePerson); | ||
await after.SaveChangesAsync(); | ||
|
||
// Migrate to migration before the one to test and thereby revert it | ||
|