using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Marco.Pms.DataAccess.Migrations { /// public partial class Added_ProjectBranches_Table : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.UpdateData( table: "Projects", keyColumn: "ContactPerson", keyValue: null, column: "ContactPerson", value: ""); migrationBuilder.AlterColumn( name: "ContactPerson", table: "Projects", type: "longtext", nullable: false, oldClrType: typeof(string), oldType: "longtext", oldNullable: true) .Annotation("MySql:CharSet", "utf8mb4") .OldAnnotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateTable( name: "ProjectBranches", columns: table => new { Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), BranchName = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), ProjectId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), ContactInformation = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), Address = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), BranchType = table.Column(type: "longtext", nullable: false) .Annotation("MySql:CharSet", "utf8mb4"), GoogleMapUrl = table.Column(type: "longtext", nullable: true) .Annotation("MySql:CharSet", "utf8mb4"), IsActive = table.Column(type: "tinyint(1)", nullable: false), CreatedAt = table.Column(type: "datetime(6)", nullable: false), CreatedById = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), UpdatedAt = table.Column(type: "datetime(6)", nullable: true), UpdatedById = table.Column(type: "char(36)", nullable: true, collation: "ascii_general_ci"), TenantId = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci") }, constraints: table => { table.PrimaryKey("PK_ProjectBranches", x => x.Id); table.ForeignKey( name: "FK_ProjectBranches_Employees_CreatedById", column: x => x.CreatedById, principalTable: "Employees", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ProjectBranches_Employees_UpdatedById", column: x => x.UpdatedById, principalTable: "Employees", principalColumn: "Id"); table.ForeignKey( name: "FK_ProjectBranches_ServiceProjects_ProjectId", column: x => x.ProjectId, principalTable: "ServiceProjects", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_ProjectBranches_Tenants_TenantId", column: x => x.TenantId, principalTable: "Tenants", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }) .Annotation("MySql:CharSet", "utf8mb4"); migrationBuilder.CreateIndex( name: "IX_ProjectBranches_CreatedById", table: "ProjectBranches", column: "CreatedById"); migrationBuilder.CreateIndex( name: "IX_ProjectBranches_ProjectId", table: "ProjectBranches", column: "ProjectId"); migrationBuilder.CreateIndex( name: "IX_ProjectBranches_TenantId", table: "ProjectBranches", column: "TenantId"); migrationBuilder.CreateIndex( name: "IX_ProjectBranches_UpdatedById", table: "ProjectBranches", column: "UpdatedById"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "ProjectBranches"); migrationBuilder.AlterColumn( name: "ContactPerson", table: "Projects", type: "longtext", nullable: true, oldClrType: typeof(string), oldType: "longtext") .Annotation("MySql:CharSet", "utf8mb4") .OldAnnotation("MySql:CharSet", "utf8mb4"); } } }