using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace wtmProject.DataAccess.Migrations { public partial class hmr2024041701 : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AddColumn( name: "CustomClass", table: "WTM_CUSTOM", type: "int", nullable: true); migrationBuilder.AddColumn( name: "DisplayOrder", table: "FrameworkUsers", type: "int", nullable: true); migrationBuilder.CreateTable( name: "WTM_CONTRACT", columns: table => new { ID = table.Column(type: "uniqueidentifier", nullable: false), TenantCode = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), CustomId = table.Column(type: "uniqueidentifier", nullable: true), CustomClass = table.Column(type: "int", nullable: true), AreaId = table.Column(type: "uniqueidentifier", nullable: true), VisitObjectId = table.Column(type: "uniqueidentifier", nullable: true), MarkManageId = table.Column(type: "uniqueidentifier", nullable: true), ProjectId = table.Column(type: "uniqueidentifier", nullable: true), ContractName = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), ContractCode = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), SignDate = table.Column(type: "datetime2", nullable: true), ContractAmount = table.Column(type: "decimal(18,2)", nullable: true), CostAmount = table.Column(type: "decimal(18,2)", nullable: true), ContractCycle = table.Column(type: "int", nullable: true), ProjectManageId = table.Column(type: "uniqueidentifier", nullable: true), GrossProfitMargin = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), CreateTime = table.Column(type: "datetime2", nullable: true), CreateBy = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "datetime2", nullable: true), UpdateBy = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_WTM_CONTRACT", x => x.ID); table.ForeignKey( name: "FK_WTM_CONTRACT_FrameworkUsers_MarkManageId", column: x => x.MarkManageId, principalTable: "FrameworkUsers", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_CONTRACT_FrameworkUsers_ProjectManageId", column: x => x.ProjectManageId, principalTable: "FrameworkUsers", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_CONTRACT_WTM_AREA_AreaId", column: x => x.AreaId, principalTable: "WTM_AREA", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_CONTRACT_WTM_CUSTOM_CustomId", column: x => x.CustomId, principalTable: "WTM_CUSTOM", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_CONTRACT_WTM_CUSTOM_PERSON_VisitObjectId", column: x => x.VisitObjectId, principalTable: "WTM_CUSTOM_PERSON", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_CONTRACT_WTM_PROJECT_ProjectId", column: x => x.ProjectId, principalTable: "WTM_PROJECT", principalColumn: "ID"); }); migrationBuilder.CreateTable( name: "WTM_BILLING_LIST", columns: table => new { ID = table.Column(type: "uniqueidentifier", nullable: false), TenantCode = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), ContractId = table.Column(type: "uniqueidentifier", nullable: true), CustomId = table.Column(type: "uniqueidentifier", nullable: true), VisitObjectId = table.Column(type: "uniqueidentifier", nullable: true), ContractAmount = table.Column(type: "decimal(18,2)", nullable: true), ProjectId = table.Column(type: "uniqueidentifier", nullable: true), ContractCycle = table.Column(type: "int", nullable: true), ProjectManageId = table.Column(type: "uniqueidentifier", nullable: true), MarkManageId = table.Column(type: "uniqueidentifier", nullable: true), BillingCycle = table.Column(type: "int", nullable: true), BillingAmount = table.Column(type: "decimal(18,2)", nullable: true), BillingDate = table.Column(type: "datetime2", nullable: true), ReceivedStatus = table.Column(type: "int", nullable: true), ReceivedDate = table.Column(type: "datetime2", nullable: true), CheckStatus = table.Column(type: "int", nullable: true), CreateTime = table.Column(type: "datetime2", nullable: true), CreateBy = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), UpdateTime = table.Column(type: "datetime2", nullable: true), UpdateBy = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true) }, constraints: table => { table.PrimaryKey("PK_WTM_BILLING_LIST", x => x.ID); table.ForeignKey( name: "FK_WTM_BILLING_LIST_FrameworkUsers_MarkManageId", column: x => x.MarkManageId, principalTable: "FrameworkUsers", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_BILLING_LIST_FrameworkUsers_ProjectManageId", column: x => x.ProjectManageId, principalTable: "FrameworkUsers", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_BILLING_LIST_WTM_CONTRACT_ContractId", column: x => x.ContractId, principalTable: "WTM_CONTRACT", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_BILLING_LIST_WTM_CUSTOM_CustomId", column: x => x.CustomId, principalTable: "WTM_CUSTOM", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_BILLING_LIST_WTM_CUSTOM_PERSON_VisitObjectId", column: x => x.VisitObjectId, principalTable: "WTM_CUSTOM_PERSON", principalColumn: "ID"); table.ForeignKey( name: "FK_WTM_BILLING_LIST_WTM_PROJECT_ProjectId", column: x => x.ProjectId, principalTable: "WTM_PROJECT", principalColumn: "ID"); }); migrationBuilder.CreateTable( name: "WTM_CONTRACT_FILE", columns: table => new { ID = table.Column(type: "uniqueidentifier", nullable: false), ContractId = table.Column(type: "uniqueidentifier", nullable: false), FileId = table.Column(type: "uniqueidentifier", nullable: false), Order = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_WTM_CONTRACT_FILE", x => x.ID); table.ForeignKey( name: "FK_WTM_CONTRACT_FILE_FileAttachments_FileId", column: x => x.FileId, principalTable: "FileAttachments", principalColumn: "ID", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_WTM_CONTRACT_FILE_WTM_CONTRACT_ContractId", column: x => x.ContractId, principalTable: "WTM_CONTRACT", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "WTM_BILLING_LIST_BILLING_FILE", columns: table => new { ID = table.Column(type: "uniqueidentifier", nullable: false), BillingId = table.Column(type: "uniqueidentifier", nullable: false), FileId = table.Column(type: "uniqueidentifier", nullable: false), Order = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_WTM_BILLING_LIST_BILLING_FILE", x => x.ID); table.ForeignKey( name: "FK_WTM_BILLING_LIST_BILLING_FILE_FileAttachments_FileId", column: x => x.FileId, principalTable: "FileAttachments", principalColumn: "ID", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_WTM_BILLING_LIST_BILLING_FILE_WTM_BILLING_LIST_BillingId", column: x => x.BillingId, principalTable: "WTM_BILLING_LIST", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "WTM_BILLING_LIST_RECEIVED_FILE", columns: table => new { ID = table.Column(type: "uniqueidentifier", nullable: false), BillingId = table.Column(type: "uniqueidentifier", nullable: false), FileId = table.Column(type: "uniqueidentifier", nullable: false), Order = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_WTM_BILLING_LIST_RECEIVED_FILE", x => x.ID); table.ForeignKey( name: "FK_WTM_BILLING_LIST_RECEIVED_FILE_FileAttachments_FileId", column: x => x.FileId, principalTable: "FileAttachments", principalColumn: "ID", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_WTM_BILLING_LIST_RECEIVED_FILE_WTM_BILLING_LIST_BillingId", column: x => x.BillingId, principalTable: "WTM_BILLING_LIST", principalColumn: "ID", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_ContractId", table: "WTM_BILLING_LIST", column: "ContractId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_CustomId", table: "WTM_BILLING_LIST", column: "CustomId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_MarkManageId", table: "WTM_BILLING_LIST", column: "MarkManageId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_ProjectId", table: "WTM_BILLING_LIST", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_ProjectManageId", table: "WTM_BILLING_LIST", column: "ProjectManageId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_VisitObjectId", table: "WTM_BILLING_LIST", column: "VisitObjectId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_BILLING_FILE_BillingId", table: "WTM_BILLING_LIST_BILLING_FILE", column: "BillingId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_BILLING_FILE_FileId", table: "WTM_BILLING_LIST_BILLING_FILE", column: "FileId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_RECEIVED_FILE_BillingId", table: "WTM_BILLING_LIST_RECEIVED_FILE", column: "BillingId"); migrationBuilder.CreateIndex( name: "IX_WTM_BILLING_LIST_RECEIVED_FILE_FileId", table: "WTM_BILLING_LIST_RECEIVED_FILE", column: "FileId"); migrationBuilder.CreateIndex( name: "IX_WTM_CONTRACT_AreaId", table: "WTM_CONTRACT", column: "AreaId"); migrationBuilder.CreateIndex( name: "IX_WTM_CONTRACT_CustomId", table: "WTM_CONTRACT", column: "CustomId"); migrationBuilder.CreateIndex( name: "IX_WTM_CONTRACT_MarkManageId", table: "WTM_CONTRACT", column: "MarkManageId"); migrationBuilder.CreateIndex( name: "IX_WTM_CONTRACT_ProjectId", table: "WTM_CONTRACT", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_WTM_CONTRACT_ProjectManageId", table: "WTM_CONTRACT", column: "ProjectManageId"); migrationBuilder.CreateIndex( name: "IX_WTM_CONTRACT_VisitObjectId", table: "WTM_CONTRACT", column: "VisitObjectId"); migrationBuilder.CreateIndex( name: "IX_WTM_CONTRACT_FILE_ContractId", table: "WTM_CONTRACT_FILE", column: "ContractId"); migrationBuilder.CreateIndex( name: "IX_WTM_CONTRACT_FILE_FileId", table: "WTM_CONTRACT_FILE", column: "FileId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "WTM_BILLING_LIST_BILLING_FILE"); migrationBuilder.DropTable( name: "WTM_BILLING_LIST_RECEIVED_FILE"); migrationBuilder.DropTable( name: "WTM_CONTRACT_FILE"); migrationBuilder.DropTable( name: "WTM_BILLING_LIST"); migrationBuilder.DropTable( name: "WTM_CONTRACT"); migrationBuilder.DropColumn( name: "CustomClass", table: "WTM_CUSTOM"); migrationBuilder.DropColumn( name: "DisplayOrder", table: "FrameworkUsers"); } } }