digdir / dialogporten

Dialogporten - common API and and metadata state store for digital dialogs
https://docs.altinn.studio/dialogporten
MIT License
1 stars 3 forks source link

chore: Fix migration for DialogElements renaming to Attachments #879

Closed oskogstad closed 3 months ago

oskogstad commented 3 months ago

Did not properly check that the migration worked with data in the database 🤦🏼 Instead of

            migrationBuilder.RenameColumn(
                name: "ElementId",
                table: "LocalizationSet",
                newName: "AttachmentId");

            migrationBuilder.RenameIndex(
                name: "IX_LocalizationSet_ElementId",
                table: "LocalizationSet",
                newName: "IX_LocalizationSet_AttachmentId");

we need to drop the column, or else we get an FK error on the old ElementIds against the new attachment table.

            migrationBuilder.DropIndex(
                name: "IX_LocalizationSet_ElementId",
                table: "LocalizationSet");

            migrationBuilder.DropColumn(
                name: "ElementId",
                table: "LocalizationSet");

            migrationBuilder.AddColumn<Guid>(
                name: "AttachmentId",
                table: "LocalizationSet",
                type: "uuid",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_LocalizationSet_AttachmentId",
                table: "LocalizationSet",
                column: "AttachmentId",
                unique: true);
sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
1 New issue
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud