using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace X1.Infrastructure.Migrations { /// public partial class UpdateNetworkStackConfigAndBindings : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Stack_CoreIMS_Bindings_CoreNetworkConfigs_CnId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropForeignKey( name: "FK_Stack_CoreIMS_Bindings_IMS_Configurations_ImsId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropForeignKey( name: "FK_Stack_CoreIMS_Bindings_NetworkStackConfigs_StackId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropIndex( name: "IX_Stack_CoreIMS_Bindings_StackId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropIndex( name: "IX_Stack_CoreIMS_Bindings_StackId_Index", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropUniqueConstraint( name: "AK_NetworkStackConfigs_StackId", table: "NetworkStackConfigs"); migrationBuilder.DropIndex( name: "IX_NetworkStackConfigs_StackId", table: "NetworkStackConfigs"); migrationBuilder.DropColumn( name: "CreatedAt", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropColumn( name: "CreatedBy", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropColumn( name: "IsDeleted", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropColumn( name: "StackId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropColumn( name: "UpdatedAt", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropColumn( name: "UpdatedBy", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropColumn( name: "StackId", table: "NetworkStackConfigs"); migrationBuilder.AddColumn( name: "NetworkStackConfigId", table: "Stack_CoreIMS_Bindings", type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "", comment: "网络栈配置ID"); migrationBuilder.AddColumn( name: "NetworkStackName", table: "NetworkStackConfigs", type: "character varying(100)", maxLength: 100, nullable: false, defaultValue: "", comment: "网络栈名称"); migrationBuilder.CreateIndex( name: "IX_Stack_CoreIMS_Bindings_NetworkStackConfigId", table: "Stack_CoreIMS_Bindings", column: "NetworkStackConfigId"); migrationBuilder.CreateIndex( name: "IX_Stack_CoreIMS_Bindings_NetworkStackConfigId_Index", table: "Stack_CoreIMS_Bindings", columns: new[] { "NetworkStackConfigId", "Index" }, unique: true); migrationBuilder.CreateIndex( name: "IX_NetworkStackConfigs_NetworkStackName", table: "NetworkStackConfigs", column: "NetworkStackName", unique: true); migrationBuilder.AddForeignKey( name: "FK_Stack_CoreIMS_Bindings_CoreNetworkConfigs_CnId", table: "Stack_CoreIMS_Bindings", column: "CnId", principalTable: "CoreNetworkConfigs", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Stack_CoreIMS_Bindings_IMS_Configurations_ImsId", table: "Stack_CoreIMS_Bindings", column: "ImsId", principalTable: "IMS_Configurations", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_Stack_CoreIMS_Bindings_NetworkStackConfigs_NetworkStackConf~", table: "Stack_CoreIMS_Bindings", column: "NetworkStackConfigId", principalTable: "NetworkStackConfigs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Stack_CoreIMS_Bindings_CoreNetworkConfigs_CnId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropForeignKey( name: "FK_Stack_CoreIMS_Bindings_IMS_Configurations_ImsId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropForeignKey( name: "FK_Stack_CoreIMS_Bindings_NetworkStackConfigs_NetworkStackConf~", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropIndex( name: "IX_Stack_CoreIMS_Bindings_NetworkStackConfigId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropIndex( name: "IX_Stack_CoreIMS_Bindings_NetworkStackConfigId_Index", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropIndex( name: "IX_NetworkStackConfigs_NetworkStackName", table: "NetworkStackConfigs"); migrationBuilder.DropColumn( name: "NetworkStackConfigId", table: "Stack_CoreIMS_Bindings"); migrationBuilder.DropColumn( name: "NetworkStackName", table: "NetworkStackConfigs"); migrationBuilder.AddColumn( name: "CreatedAt", table: "Stack_CoreIMS_Bindings", type: "timestamp with time zone", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), comment: "创建时间"); migrationBuilder.AddColumn( name: "CreatedBy", table: "Stack_CoreIMS_Bindings", type: "text", nullable: false, defaultValue: ""); migrationBuilder.AddColumn( name: "IsDeleted", table: "Stack_CoreIMS_Bindings", type: "boolean", nullable: false, defaultValue: false); migrationBuilder.AddColumn( name: "StackId", table: "Stack_CoreIMS_Bindings", type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "", comment: "栈ID"); migrationBuilder.AddColumn( name: "UpdatedAt", table: "Stack_CoreIMS_Bindings", type: "timestamp with time zone", nullable: false, defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), comment: "更新时间"); migrationBuilder.AddColumn( name: "UpdatedBy", table: "Stack_CoreIMS_Bindings", type: "text", nullable: true); migrationBuilder.AddColumn( name: "StackId", table: "NetworkStackConfigs", type: "character varying(50)", maxLength: 50, nullable: false, defaultValue: "", comment: "栈ID"); migrationBuilder.AddUniqueConstraint( name: "AK_NetworkStackConfigs_StackId", table: "NetworkStackConfigs", column: "StackId"); migrationBuilder.CreateIndex( name: "IX_Stack_CoreIMS_Bindings_StackId", table: "Stack_CoreIMS_Bindings", column: "StackId"); migrationBuilder.CreateIndex( name: "IX_Stack_CoreIMS_Bindings_StackId_Index", table: "Stack_CoreIMS_Bindings", columns: new[] { "StackId", "Index" }, unique: true); migrationBuilder.CreateIndex( name: "IX_NetworkStackConfigs_StackId", table: "NetworkStackConfigs", column: "StackId", unique: true); migrationBuilder.AddForeignKey( name: "FK_Stack_CoreIMS_Bindings_CoreNetworkConfigs_CnId", table: "Stack_CoreIMS_Bindings", column: "CnId", principalTable: "CoreNetworkConfigs", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Stack_CoreIMS_Bindings_IMS_Configurations_ImsId", table: "Stack_CoreIMS_Bindings", column: "ImsId", principalTable: "IMS_Configurations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_Stack_CoreIMS_Bindings_NetworkStackConfigs_StackId", table: "Stack_CoreIMS_Bindings", column: "StackId", principalTable: "NetworkStackConfigs", principalColumn: "StackId", onDelete: ReferentialAction.Cascade); } } }