Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 140 additions & 35 deletions src/NetCorePal.D3Shop.Web/Migrations/20250310120744_addOpeniddict.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@ public partial class addOpeniddict : Migration
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_rolePermissions_roles_RoleId",
table: "rolePermissions");

migrationBuilder.AlterColumn<long>(
name: "Id",
table: "roles",
type: "bigint",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.None);

migrationBuilder.AddForeignKey(
name: "FK_rolePermissions_roles_RoleId",
table: "rolePermissions",
column: "RoleId",
principalTable: "roles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade,
onUpdate:ReferentialAction.Restrict);


migrationBuilder.AlterColumn<long>(
name: "Id",
Expand All @@ -30,14 +45,28 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldType: "bigint")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

migrationBuilder.DropForeignKey(
name: "FK_departmentUser_departments_DeptId",
table: "departmentUser");

migrationBuilder.AlterColumn<long>(
name: "Id",
table: "departments",
type: "bigint",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.None);

migrationBuilder.AddForeignKey(
name: "FK_departmentUser_departments_DeptId",
table: "departmentUser",
column: "DeptId",
principalTable: "departments",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict,
onUpdate:ReferentialAction.Restrict);

migrationBuilder.AlterColumn<long>(
name: "Id",
Expand All @@ -58,35 +87,67 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldType: "datetime(6)",
oldNullable: true);

// 手动删除外键

migrationBuilder.DropForeignKey(
name: "FK_userDeliveryAddresses_clientUsers_UserId",
table: "userDeliveryAddresses");

migrationBuilder.DropForeignKey(
name: "FK_userThirdPartyLogins_clientUsers_UserId",
table: "userThirdPartyLogins");


migrationBuilder.AlterColumn<long>(
name: "Id",
table: "clientUsers",
type: "bigint",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

migrationBuilder.AddColumn<DateTime>(
name: "LoginExpiryDate",
table: "clientUsers",
type: "datetime(6)",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

migrationBuilder.AddColumn<string>(
name: "PasswordSalt",
table: "clientUsers",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");

migrationBuilder.AddColumn<string>(
name: "RefreshToken",
table: "clientUsers",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.None);

migrationBuilder.AddForeignKey(
name: "FK_userDeliveryAddresses_clientUsers_UserId",
table: "userDeliveryAddresses",
column: "UserId",
principalTable: "clientUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict,
onUpdate:ReferentialAction.Restrict);

migrationBuilder.AddForeignKey(
name: "FK_userThirdPartyLogins_clientUsers_UserId",
table: "userThirdPartyLogins",
column: "UserId",
principalTable: "clientUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict,
onUpdate:ReferentialAction.Restrict);



// migrationBuilder.AddColumn<DateTime>(
// name: "LoginExpiryDate",
// table: "clientUsers",
// type: "datetime(6)",
// nullable: false,
// defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

// migrationBuilder.AddColumn<string>(
// name: "PasswordSalt",
// table: "clientUsers",
// type: "longtext",
// nullable: false)
// .Annotation("MySql:CharSet", "utf8mb4");
//
// migrationBuilder.AddColumn<string>(
// name: "RefreshToken",
// table: "clientUsers",
// type: "longtext",
// nullable: false)
// .Annotation("MySql:CharSet", "utf8mb4");

migrationBuilder.AlterColumn<long>(
name: "Id",
Expand All @@ -97,15 +158,59 @@ protected override void Up(MigrationBuilder migrationBuilder)
oldType: "bigint")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);



migrationBuilder.DropForeignKey(
name: "FK_adminUserPermissions_adminUsers_AdminUserId",
table: "adminUserPermissions");

migrationBuilder.DropForeignKey(
name: "FK_adminUserRoles_adminUsers_AdminUserId",
table: "adminUserRoles");

migrationBuilder.DropForeignKey(
name: "FK_userDepts_adminUsers_AdminUserId",
table: "userDepts");

migrationBuilder.AlterColumn<long>(
name: "Id",
table: "adminUsers",
type: "bigint",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint")
.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

.OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.None);


migrationBuilder.AddForeignKey(
name: "FK_adminUserPermissions_adminUsers_AdminUserId",
table: "adminUserPermissions",
column: "AdminUserId",
principalTable: "adminUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict,
onUpdate:ReferentialAction.Restrict);

migrationBuilder.AddForeignKey(
name: "FK_adminUserRoles_adminUsers_AdminUserId",
table: "adminUserRoles",
column: "AdminUserId",
principalTable: "adminUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict,
onUpdate:ReferentialAction.Restrict);

migrationBuilder.AddForeignKey(
name: "FK_userDepts_adminUsers_AdminUserId",
table: "userDepts",
column: "AdminUserId",
principalTable: "adminUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict,
onUpdate:ReferentialAction.Restrict);


migrationBuilder.CreateTable(
name: "OpenIddictApplications",
columns: table => new
Expand Down Expand Up @@ -304,17 +409,17 @@ protected override void Down(MigrationBuilder migrationBuilder)
migrationBuilder.DropTable(
name: "OpenIddictApplications");

migrationBuilder.DropColumn(
name: "LoginExpiryDate",
table: "clientUsers");
// migrationBuilder.DropColumn(
// name: "LoginExpiryDate",
// table: "clientUsers");

migrationBuilder.DropColumn(
name: "PasswordSalt",
table: "clientUsers");
// migrationBuilder.DropColumn(
// name: "PasswordSalt",
// table: "clientUsers");

migrationBuilder.DropColumn(
name: "RefreshToken",
table: "clientUsers");
// migrationBuilder.DropColumn(
// name: "RefreshToken",
// table: "clientUsers");

migrationBuilder.AlterColumn<long>(
name: "Id",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public partial class useDatetimeOffset : Migration
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "RefreshToken",
table: "clientUsers");
// migrationBuilder.DropColumn(
// name: "RefreshToken",
// table: "clientUsers");

migrationBuilder.AlterColumn<long>(
name: "Id",
Expand Down Expand Up @@ -154,12 +154,12 @@ protected override void Down(MigrationBuilder migrationBuilder)
oldType: "bigint")
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);

migrationBuilder.AddColumn<string>(
name: "RefreshToken",
table: "clientUsers",
type: "longtext",
nullable: false)
.Annotation("MySql:CharSet", "utf8mb4");
// migrationBuilder.AddColumn<string>(
// name: "RefreshToken",
// table: "clientUsers",
// type: "longtext",
// nullable: false)
// .Annotation("MySql:CharSet", "utf8mb4");
}
}
}
2 changes: 1 addition & 1 deletion src/NetCorePal.D3Shop.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
builder.Services.AddDbContext<ApplicationDbContext>(options =>
{
options.UseMySql(builder.Configuration.GetConnectionString("MySql"),
new MySqlServerVersion(new Version(8, 0, 34)),
ServerVersion.AutoDetect(builder.Configuration.GetConnectionString("MySql")),
b =>
{
b.MigrationsAssembly(typeof(Program).Assembly.FullName);
Expand Down
Loading