Skip to content

Commit d3a67fe

Browse files
kjacbergmania
authored andcommitted
Move all V14 User and User Group migration to pre-migrations (#17130)
(cherry picked from commit 910d703)
1 parent 0c1daa2 commit d3a67fe

File tree

4 files changed

+20
-20
lines changed

4 files changed

+20
-20
lines changed

src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPlan.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ protected virtual void DefinePlan()
6767

6868
// To 14.0.0
6969
To<V_14_0_0.AddPropertyEditorUiAliasColumn>("{419827A0-4FCE-464B-A8F3-247C6092AF55}");
70-
To<V_14_0_0.AddGuidsToUserGroups>("{69E12556-D9B3-493A-8E8A-65EC89FB658D}");
71-
To<V_14_0_0.AddUserGroup2PermisionTable>("{F2B16CD4-F181-4BEE-81C9-11CF384E6025}");
72-
To<V_14_0_0.AddGuidsToUsers>("{A8E01644-9F2E-4988-8341-587EF5B7EA69}");
70+
To<NoopMigration>("{69E12556-D9B3-493A-8E8A-65EC89FB658D}");
71+
To<NoopMigration>("{F2B16CD4-F181-4BEE-81C9-11CF384E6025}");
72+
To<NoopMigration>("{A8E01644-9F2E-4988-8341-587EF5B7EA69}");
7373
To<V_14_0_0.UpdateDefaultGuidsOfCreatedPackages>("{E073DBC0-9E8E-4C92-8210-9CB18364F46E}");
7474
To<V_14_0_0.RenameTechnologyLeakingPropertyEditorAliases>("{80D282A4-5497-47FF-991F-BC0BCE603121}");
7575
To<V_14_0_0.MigrateSchduledPublishesToUtc>("{96525697-E9DC-4198-B136-25AD033442B8}");
7676
To<V_14_0_0.AddListViewKeysToDocumentTypes>("{7FC5AC9B-6F56-415B-913E-4A900629B853}");
7777
To<V_14_0_0.MigrateDataTypeConfigurations>("{1539A010-2EB5-4163-8518-4AE2AA98AFC6}");
78-
To<V_14_0_0.MigrateCharPermissionsToStrings>("{C567DE81-DF92-4B99-BEA8-CD34EF99DA5D}");
78+
To<NoopMigration>("{C567DE81-DF92-4B99-BEA8-CD34EF99DA5D}");
7979
To<V_14_0_0.DeleteMacroTables>("{0D82C836-96DD-480D-A924-7964E458BD34}");
8080
To<V_14_0_0.MoveDocumentBlueprintsToFolders>("{1A0FBC8A-6FC6-456C-805C-B94816B2E570}");
8181
To<V_14_0_0.MigrateTours>("{302DE171-6D83-4B6B-B3C0-AC8808A16CA1}");

src/Umbraco.Infrastructure/Migrations/Upgrade/UmbracoPremigrationPlan.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,9 @@ protected virtual void DefinePlan()
5353

5454
// To 14.0.0
5555
To<V_14_0_0.UpdateToOpenIddictV5>("{76FBF80E-37E6-462E-ADC1-25668F56151D}");
56+
To<V_14_0_0.AddGuidsToUserGroups>("{37CF4AC3-8489-44BC-A7E8-64908FEEC656}");
57+
To<V_14_0_0.AddUserGroup2PermisionTable>("{7BCB5352-B2ED-4D4B-B27D-ECDED930B50A}");
58+
To<V_14_0_0.AddGuidsToUsers>("{3E69BF9B-BEAB-41B1-BB11-15383CCA1C7F}");
59+
To<V_14_0_0.MigrateCharPermissionsToStrings>("{F12C609B-86B9-4386-AFA4-78E02857247C}");
5660
}
5761
}

src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddGuidsToUserGroups.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ public AddGuidsToUserGroups(IMigrationContext context, IScopeProvider scopeProvi
2020

2121
protected override void Migrate()
2222
{
23+
// If the new column already exists we'll do nothing.
24+
if (ColumnExists(Constants.DatabaseSchema.Tables.UserGroup, NewColumnName))
25+
{
26+
return;
27+
}
28+
2329
// SQL server can simply add the column, but for SQLite this won't work,
2430
// so we'll have to create a new table and copy over data.
2531
if (DatabaseType != DatabaseType.SQLite)
@@ -37,11 +43,6 @@ private void MigrateSqlServer()
3743
using IDisposable notificationSuppression = scope.Notifications.Suppress();
3844
ScopeDatabase(scope);
3945

40-
if (ColumnExists(Constants.DatabaseSchema.Tables.UserGroup, NewColumnName))
41-
{
42-
return;
43-
}
44-
4546
var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList();
4647
AddColumnIfNotExists<UserGroupDto>(columns, NewColumnName);
4748

@@ -68,12 +69,6 @@ private void MigrateSqlite()
6869
using IDisposable notificationSuppression = scope.Notifications.Suppress();
6970
ScopeDatabase(scope);
7071

71-
// If the new column already exists we'll do nothing.
72-
if (ColumnExists(Constants.DatabaseSchema.Tables.UserGroup, NewColumnName))
73-
{
74-
return;
75-
}
76-
7772
// This isn't pretty,
7873
// But since you cannot alter columns, we have to copy the data over and delete the old table.
7974
// However we cannot do this due to foreign keys, so temporarily disable these keys while migrating.

src/Umbraco.Infrastructure/Migrations/Upgrade/V_14_0_0/AddGuidsToUsers.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ public AddGuidsToUsers(IMigrationContext context, IScopeProvider scopeProvider)
2626

2727
protected override void Migrate()
2828
{
29+
if (ColumnExists(Constants.DatabaseSchema.Tables.User, NewColumnName))
30+
{
31+
Context.Complete();
32+
return;
33+
}
34+
2935
InvalidateBackofficeUserAccess = true;
3036
using IScope scope = _scopeProvider.CreateScope();
3137
using IDisposable notificationSuppression = scope.Notifications.Suppress();
@@ -75,11 +81,6 @@ private void MigrateSqlServer()
7581

7682
private void MigrateSqlite()
7783
{
78-
if (ColumnExists(Constants.DatabaseSchema.Tables.User, NewColumnName))
79-
{
80-
return;
81-
}
82-
8384
/*
8485
* We commit the initial transaction started by the scope. This is required in order to disable the foreign keys.
8586
* We then begin a new transaction, this transaction will be committed or rolled back by the scope, like normal.

0 commit comments

Comments
 (0)