diff options
| author | Jake Mannens <jake@asger.xyz> | 2023-10-20 14:26:02 +1100 |
|---|---|---|
| committer | Jake Mannens <jake@asger.xyz> | 2023-10-20 14:26:02 +1100 |
| commit | 02670870b2711db0984f492d452a90477c67608a (patch) | |
| tree | a6c15f627535dd962042d2e000c093cf2ae63956 /Migrations/20231020031326_NullableCurrentUploadedFile.cs | |
| parent | 07728d1048f34e1d048da63684b341ab30bc1d06 (diff) | |
Gallery
Diffstat (limited to 'Migrations/20231020031326_NullableCurrentUploadedFile.cs')
| -rw-r--r-- | Migrations/20231020031326_NullableCurrentUploadedFile.cs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Migrations/20231020031326_NullableCurrentUploadedFile.cs b/Migrations/20231020031326_NullableCurrentUploadedFile.cs new file mode 100644 index 0000000..5159d16 --- /dev/null +++ b/Migrations/20231020031326_NullableCurrentUploadedFile.cs @@ -0,0 +1,97 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace HyperBooru.Migrations +{ + /// <inheritdoc /> + public partial class NullableCurrentUploadedFile : Migration + { + /// <inheritdoc /> + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Media_UploadedFiles_CurrentUploadedFileId", + table: "Media"); + + migrationBuilder.DropColumn( + name: "DisplayName", + table: "SecurityPrincipals"); + + migrationBuilder.AlterColumn<byte[]>( + name: "Owner", + table: "Objects", + type: "bytea", + nullable: false, + defaultValue: new byte[] { 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, + oldClrType: typeof(byte[]), + oldType: "bytea", + oldDefaultValue: new byte[] { 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }); + + migrationBuilder.AlterColumn<int>( + name: "CurrentUploadedFileId", + table: "Media", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AddForeignKey( + name: "FK_Media_UploadedFiles_CurrentUploadedFileId", + table: "Media", + column: "CurrentUploadedFileId", + principalTable: "UploadedFiles", + principalColumn: "ObjectId"); + } + + /// <inheritdoc /> + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Media_UploadedFiles_CurrentUploadedFileId", + table: "Media"); + + migrationBuilder.AddColumn<string>( + name: "DisplayName", + table: "SecurityPrincipals", + type: "text", + nullable: false, + defaultValue: ""); + + migrationBuilder.AlterColumn<byte[]>( + name: "Owner", + table: "Objects", + type: "bytea", + nullable: false, + defaultValue: new byte[] { 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }, + oldClrType: typeof(byte[]), + oldType: "bytea", + oldDefaultValue: new byte[] { 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 }); + + migrationBuilder.AlterColumn<int>( + name: "CurrentUploadedFileId", + table: "Media", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.UpdateData( + table: "SecurityPrincipals", + keyColumn: "LocalPrincipalId", + keyValue: -1, + column: "DisplayName", + value: "Administrator"); + + migrationBuilder.AddForeignKey( + name: "FK_Media_UploadedFiles_CurrentUploadedFileId", + table: "Media", + column: "CurrentUploadedFileId", + principalTable: "UploadedFiles", + principalColumn: "ObjectId", + onDelete: ReferentialAction.Cascade); + } + } +} |
