-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add database migration to limit UID and Hash max lengths
- Loading branch information
Stanley Dimant
committed
Jul 12, 2022
1 parent
b8950ca
commit e70f564
Showing
6 changed files
with
325 additions
and
11 deletions.
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
175 changes: 175 additions & 0 deletions
175
...SynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
141 changes: 141 additions & 0 deletions
141
MareSynchronosServer/MareSynchronosServer/Migrations/20220712082237_SetMaxLengths.cs
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 |
---|---|---|
@@ -0,0 +1,141 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace MareSynchronosServer.Migrations | ||
{ | ||
public partial class SetMaxLengths : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropColumn( | ||
name: "LastAccessTime", | ||
table: "FileCaches"); | ||
|
||
migrationBuilder.DropForeignKey("FK_FileCaches_Users_UploaderUID", "FileCaches"); | ||
migrationBuilder.DropForeignKey("FK_ClientPairs_Users_UserUID", "ClientPairs"); | ||
migrationBuilder.DropForeignKey("FK_ClientPairs_Users_OtherUserUID", "ClientPairs"); | ||
migrationBuilder.DropPrimaryKey("PK_FileCaches", "FileCaches"); | ||
migrationBuilder.DropPrimaryKey("PK_Users", "Users"); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "UploaderUID", | ||
table: "FileCaches", | ||
type: "nvarchar(10)", | ||
nullable: true, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(450)", | ||
oldNullable: true); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "Hash", | ||
table: "FileCaches", | ||
type: "nvarchar(40)", | ||
maxLength: 20, | ||
nullable: false, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(450)"); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "UserUID", | ||
table: "ClientPairs", | ||
type: "nvarchar(10)", | ||
nullable: true, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(450)", | ||
oldNullable: true); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "OtherUserUID", | ||
table: "ClientPairs", | ||
type: "nvarchar(10)", | ||
nullable: true, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(450)", | ||
oldNullable: true); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "UID", | ||
table: "Users", | ||
type: "nvarchar(10)", | ||
maxLength: 10, | ||
nullable: false, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(450)"); | ||
|
||
migrationBuilder.AddPrimaryKey("PK_Users", "Users", "UID"); | ||
migrationBuilder.AddPrimaryKey("PK_FileCaches", "FileCaches", "Hash"); | ||
migrationBuilder.AddForeignKey("FK_FileCaches_Users_UploaderUID", "FileCaches", "UploaderUID", "Users"); | ||
migrationBuilder.AddForeignKey("FK_ClientPairs_Users_UserUID", "ClientPairs", "UserUID", "Users"); | ||
migrationBuilder.AddForeignKey("FK_ClientPairs_Users_OtherUserUID", "ClientPairs", "UserUID", "Users"); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropForeignKey("FK_FileCaches_Users_UploaderUID", "FileCaches"); | ||
migrationBuilder.DropForeignKey("FK_ClientPairs_Users_UserUID", "ClientPairs"); | ||
migrationBuilder.DropForeignKey("FK_ClientPairs_Users_OtherUserUID", "ClientPairs"); | ||
migrationBuilder.DropPrimaryKey("PK_FileCaches", "FileCaches"); | ||
migrationBuilder.DropPrimaryKey("PK_Users", "Users"); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "UID", | ||
table: "Users", | ||
type: "nvarchar(450)", | ||
nullable: false, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(10)", | ||
oldMaxLength: 10); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "UploaderUID", | ||
table: "FileCaches", | ||
type: "nvarchar(450)", | ||
nullable: true, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(10)", | ||
oldNullable: true); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "Hash", | ||
table: "FileCaches", | ||
type: "nvarchar(450)", | ||
nullable: false, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(20)", | ||
oldMaxLength: 20); | ||
|
||
migrationBuilder.AddColumn<DateTime>( | ||
name: "LastAccessTime", | ||
table: "FileCaches", | ||
type: "datetime2", | ||
nullable: false, | ||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "UserUID", | ||
table: "ClientPairs", | ||
type: "nvarchar(450)", | ||
nullable: true, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(10)", | ||
oldNullable: true); | ||
|
||
migrationBuilder.AlterColumn<string>( | ||
name: "OtherUserUID", | ||
table: "ClientPairs", | ||
type: "nvarchar(450)", | ||
nullable: true, | ||
oldClrType: typeof(string), | ||
oldType: "nvarchar(10)", | ||
oldNullable: true); | ||
|
||
migrationBuilder.AddPrimaryKey("PK_Users", "Users", "UID"); | ||
migrationBuilder.AddPrimaryKey("PK_FileCaches", "FileCaches", "Hash"); | ||
migrationBuilder.AddForeignKey("FK_FileCaches_Users_UploaderUID", "FileCaches", "UploaderUID", "Users"); | ||
migrationBuilder.AddForeignKey("FK_ClientPairs_Users_UserUID", "ClientPairs", "UserUID", "Users"); | ||
migrationBuilder.AddForeignKey("FK_ClientPairs_Users_OtherUserUID", "ClientPairs", "UserUID", "Users"); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.