using System; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Marco.Pms.DataAccess.Migrations { /// public partial class TaskAllocationModels : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_ActivityMasters_TaskAllocations_TaskAllocationId", table: "ActivityMasters"); migrationBuilder.DropForeignKey( name: "FK_TaskAllocations_Buildings_BuildingId", table: "TaskAllocations"); migrationBuilder.DropForeignKey( name: "FK_TaskAllocations_Employees_EmployeeId", table: "TaskAllocations"); migrationBuilder.DropForeignKey( name: "FK_TaskAllocations_Projects_ProjectId", table: "TaskAllocations"); migrationBuilder.DropForeignKey( name: "FK_TaskAllocations_WorkAreas_WorkAreaId", table: "TaskAllocations"); migrationBuilder.DropIndex( name: "IX_TaskAllocations_BuildingId", table: "TaskAllocations"); migrationBuilder.DropIndex( name: "IX_TaskAllocations_EmployeeId", table: "TaskAllocations"); migrationBuilder.DropIndex( name: "IX_ActivityMasters_TaskAllocationId", table: "ActivityMasters"); migrationBuilder.DropColumn( name: "BuildingId", table: "TaskAllocations"); migrationBuilder.DropColumn( name: "EmployeeId", table: "TaskAllocations"); migrationBuilder.DropColumn( name: "TaskAllocationId", table: "ActivityMasters"); migrationBuilder.RenameColumn( name: "WorkAreaId", table: "TaskAllocations", newName: "WorkItemMappingId"); migrationBuilder.RenameColumn( name: "ReAllocationDate", table: "TaskAllocations", newName: "ReportedDate"); migrationBuilder.RenameColumn( name: "ProjectId", table: "TaskAllocations", newName: "WorkItemId"); migrationBuilder.RenameColumn( name: "EmployeeRole", table: "TaskAllocations", newName: "AssignedBy"); migrationBuilder.RenameColumn( name: "AllocationDate", table: "TaskAllocations", newName: "AssignmentDate"); migrationBuilder.RenameIndex( name: "IX_TaskAllocations_WorkAreaId", table: "TaskAllocations", newName: "IX_TaskAllocations_WorkItemMappingId"); migrationBuilder.RenameIndex( name: "IX_TaskAllocations_ProjectId", table: "TaskAllocations", newName: "IX_TaskAllocations_WorkItemId"); migrationBuilder.AlterColumn( name: "PlannedWork", table: "WorkItems", type: "double", nullable: false, oldClrType: typeof(int), oldType: "int"); migrationBuilder.AlterColumn( name: "CompletedWork", table: "WorkItems", type: "double", nullable: false, oldClrType: typeof(int), oldType: "int"); migrationBuilder.AlterColumn( name: "Id", table: "TaskAllocations", type: "bigint", nullable: false, oldClrType: typeof(int), oldType: "int") .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); migrationBuilder.AddColumn( name: "CompletedTask", table: "TaskAllocations", type: "double", nullable: false, defaultValue: 0.0); migrationBuilder.AddColumn( name: "Description", table: "TaskAllocations", type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.AddColumn( name: "PlannedTask", table: "TaskAllocations", type: "double", nullable: false, defaultValue: 0.0); migrationBuilder.CreateTable( name: "TaskComments", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TaskAllocationId = table.Column(type: "bigint", nullable: false), CommentDate = table.Column(type: "datetime(6)", nullable: false), Comment = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), CommentedBy = table.Column(type: "int", nullable: false), TenantId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TaskComments", x => x.Id); table.ForeignKey( name: "FK_TaskComments_Employees_CommentedBy", column: x => x.CommentedBy, principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TaskComments_TaskAllocations_TaskAllocationId", column: x => x.TaskAllocationId, principalTable: "TaskAllocations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TaskComments_Tenants_TenantId", column: x => x.TenantId, principalTable: "Tenants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "TaskMembers", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), TaskAllocationId = table.Column(type: "bigint", nullable: false), EmployeeId = table.Column(type: "int", nullable: false), TenantId = table.Column(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_TaskMembers", x => x.Id); table.ForeignKey( name: "FK_TaskMembers_Employees_EmployeeId", column: x => x.EmployeeId, principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TaskMembers_TaskAllocations_TaskAllocationId", column: x => x.TaskAllocationId, principalTable: "TaskAllocations", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_TaskMembers_Tenants_TenantId", column: x => x.TenantId, principalTable: "Tenants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_TaskAllocations_AssignedBy", table: "TaskAllocations", column: "AssignedBy"); migrationBuilder.CreateIndex( name: "IX_TaskComments_CommentedBy", table: "TaskComments", column: "CommentedBy"); migrationBuilder.CreateIndex( name: "IX_TaskComments_TaskAllocationId", table: "TaskComments", column: "TaskAllocationId"); migrationBuilder.CreateIndex( name: "IX_TaskComments_TenantId", table: "TaskComments", column: "TenantId"); migrationBuilder.CreateIndex( name: "IX_TaskMembers_EmployeeId", table: "TaskMembers", column: "EmployeeId"); migrationBuilder.CreateIndex( name: "IX_TaskMembers_TaskAllocationId", table: "TaskMembers", column: "TaskAllocationId"); migrationBuilder.CreateIndex( name: "IX_TaskMembers_TenantId", table: "TaskMembers", column: "TenantId"); migrationBuilder.AddForeignKey( name: "FK_TaskAllocations_Employees_AssignedBy", table: "TaskAllocations", column: "AssignedBy", principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_TaskAllocations_WorkItemMapping_WorkItemMappingId", table: "TaskAllocations", column: "WorkItemMappingId", principalTable: "WorkItemMapping", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_TaskAllocations_WorkItems_WorkItemId", table: "TaskAllocations", column: "WorkItemId", principalTable: "WorkItems", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_TaskAllocations_Employees_AssignedBy", table: "TaskAllocations"); migrationBuilder.DropForeignKey( name: "FK_TaskAllocations_WorkItemMapping_WorkItemMappingId", table: "TaskAllocations"); migrationBuilder.DropForeignKey( name: "FK_TaskAllocations_WorkItems_WorkItemId", table: "TaskAllocations"); migrationBuilder.DropTable( name: "TaskComments"); migrationBuilder.DropTable( name: "TaskMembers"); migrationBuilder.DropIndex( name: "IX_TaskAllocations_AssignedBy", table: "TaskAllocations"); migrationBuilder.DropColumn( name: "CompletedTask", table: "TaskAllocations"); migrationBuilder.DropColumn( name: "Description", table: "TaskAllocations"); migrationBuilder.DropColumn( name: "PlannedTask", table: "TaskAllocations"); migrationBuilder.RenameColumn( name: "WorkItemMappingId", table: "TaskAllocations", newName: "WorkAreaId"); migrationBuilder.RenameColumn( name: "WorkItemId", table: "TaskAllocations", newName: "ProjectId"); migrationBuilder.RenameColumn( name: "ReportedDate", table: "TaskAllocations", newName: "ReAllocationDate"); migrationBuilder.RenameColumn( name: "AssignmentDate", table: "TaskAllocations", newName: "AllocationDate"); migrationBuilder.RenameColumn( name: "AssignedBy", table: "TaskAllocations", newName: "EmployeeRole"); migrationBuilder.RenameIndex( name: "IX_TaskAllocations_WorkItemMappingId", table: "TaskAllocations", newName: "IX_TaskAllocations_WorkAreaId"); migrationBuilder.RenameIndex( name: "IX_TaskAllocations_WorkItemId", table: "TaskAllocations", newName: "IX_TaskAllocations_ProjectId"); migrationBuilder.AlterColumn( name: "PlannedWork", table: "WorkItems", type: "int", nullable: false, oldClrType: typeof(double), oldType: "double"); migrationBuilder.AlterColumn( name: "CompletedWork", table: "WorkItems", type: "int", nullable: false, oldClrType: typeof(double), oldType: "double"); migrationBuilder.AlterColumn( name: "Id", table: "TaskAllocations", type: "int", nullable: false, oldClrType: typeof(long), oldType: "bigint") .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn) .OldAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); migrationBuilder.AddColumn( name: "BuildingId", table: "TaskAllocations", type: "int", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "EmployeeId", table: "TaskAllocations", type: "int", nullable: false, defaultValue: 0); migrationBuilder.AddColumn( name: "TaskAllocationId", table: "ActivityMasters", type: "int", nullable: true); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 1, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 2, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 3, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 4, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 5, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 6, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 7, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 8, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 9, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 10, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 11, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 12, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 13, column: "TaskAllocationId", value: null); migrationBuilder.UpdateData( table: "ActivityMasters", keyColumn: "Id", keyValue: 14, column: "TaskAllocationId", value: null); migrationBuilder.CreateIndex( name: "IX_TaskAllocations_BuildingId", table: "TaskAllocations", column: "BuildingId"); migrationBuilder.CreateIndex( name: "IX_TaskAllocations_EmployeeId", table: "TaskAllocations", column: "EmployeeId"); migrationBuilder.CreateIndex( name: "IX_ActivityMasters_TaskAllocationId", table: "ActivityMasters", column: "TaskAllocationId"); migrationBuilder.AddForeignKey( name: "FK_ActivityMasters_TaskAllocations_TaskAllocationId", table: "ActivityMasters", column: "TaskAllocationId", principalTable: "TaskAllocations", principalColumn: "Id"); migrationBuilder.AddForeignKey( name: "FK_TaskAllocations_Buildings_BuildingId", table: "TaskAllocations", column: "BuildingId", principalTable: "Buildings", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_TaskAllocations_Employees_EmployeeId", table: "TaskAllocations", column: "EmployeeId", principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_TaskAllocations_Projects_ProjectId", table: "TaskAllocations", column: "ProjectId", principalTable: "Projects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); migrationBuilder.AddForeignKey( name: "FK_TaskAllocations_WorkAreas_WorkAreaId", table: "TaskAllocations", column: "WorkAreaId", principalTable: "WorkAreas", principalColumn: "Id", onDelete: ReferentialAction.Cascade); } } }