using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Data.SeaHavenIndustries.Migrations { /// public partial class dropdowntablechange : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_workOrders_Categories_CategoryId", table: "workOrders"); migrationBuilder.DropForeignKey( name: "FK_workOrders_Contacts_ContactId", table: "workOrders"); migrationBuilder.DropIndex( name: "IX_workOrders_CategoryId", table: "workOrders"); migrationBuilder.DropIndex( name: "IX_workOrders_ContactId", table: "workOrders"); migrationBuilder.DropColumn( name: "CategoryId", table: "workOrders"); migrationBuilder.DropColumn( name: "ContactId", table: "workOrders"); migrationBuilder.AddColumn( name: "istemplate", table: "workOrders", type: "bit", nullable: true); migrationBuilder.AddColumn( name: "Status", table: "Quotes", type: "nvarchar(max)", nullable: true); migrationBuilder.CreateTable( name: "workOrderAttachments", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Attachments = table.Column(type: "nvarchar(max)", nullable: true), WorkorderId = table.Column(type: "int", nullable: true), ContactsId = table.Column(type: "int", nullable: true), IsDeleted = table.Column(type: "bit", nullable: true), createdby = table.Column(type: "nvarchar(max)", nullable: true), DeleterUserId = table.Column(type: "nvarchar(max)", nullable: true), DeletionTime = table.Column(type: "datetime2", nullable: true), CreatedDate = table.Column(type: "datetime2", nullable: true), LastModificationTime = table.Column(type: "datetime2", nullable: true), LastModifierUserId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_workOrderAttachments", x => x.Id); table.ForeignKey( name: "FK_workOrderAttachments_Contacts_ContactsId", column: x => x.ContactsId, principalTable: "Contacts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_workOrderAttachments_workOrders_WorkorderId", column: x => x.WorkorderId, principalTable: "workOrders", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "workOrderCategories", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CategoryId = table.Column(type: "int", nullable: true), WorkorderId = table.Column(type: "int", nullable: true), IsDeleted = table.Column(type: "bit", nullable: true), createdby = table.Column(type: "nvarchar(max)", nullable: true), DeleterUserId = table.Column(type: "nvarchar(max)", nullable: true), DeletionTime = table.Column(type: "datetime2", nullable: true), CreatedDate = table.Column(type: "datetime2", nullable: true), LastModificationTime = table.Column(type: "datetime2", nullable: true), LastModifierUserId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_workOrderCategories", x => x.Id); table.ForeignKey( name: "FK_workOrderCategories_Categories_CategoryId", column: x => x.CategoryId, principalTable: "Categories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_workOrderCategories_workOrders_WorkorderId", column: x => x.WorkorderId, principalTable: "workOrders", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateTable( name: "WorkOrderContacts", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), ContactId = table.Column(type: "int", nullable: true), WorkorderId = table.Column(type: "int", nullable: true), IsDeleted = table.Column(type: "bit", nullable: true), createdby = table.Column(type: "nvarchar(max)", nullable: true), DeleterUserId = table.Column(type: "nvarchar(max)", nullable: true), DeletionTime = table.Column(type: "datetime2", nullable: true), CreatedDate = table.Column(type: "datetime2", nullable: true), LastModificationTime = table.Column(type: "datetime2", nullable: true), LastModifierUserId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_WorkOrderContacts", x => x.Id); table.ForeignKey( name: "FK_WorkOrderContacts_Contacts_ContactId", column: x => x.ContactId, principalTable: "Contacts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); table.ForeignKey( name: "FK_WorkOrderContacts_workOrders_WorkorderId", column: x => x.WorkorderId, principalTable: "workOrders", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_workOrderAttachments_ContactsId", table: "workOrderAttachments", column: "ContactsId"); migrationBuilder.CreateIndex( name: "IX_workOrderAttachments_WorkorderId", table: "workOrderAttachments", column: "WorkorderId"); migrationBuilder.CreateIndex( name: "IX_workOrderCategories_CategoryId", table: "workOrderCategories", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_workOrderCategories_WorkorderId", table: "workOrderCategories", column: "WorkorderId"); migrationBuilder.CreateIndex( name: "IX_WorkOrderContacts_ContactId", table: "WorkOrderContacts", column: "ContactId"); migrationBuilder.CreateIndex( name: "IX_WorkOrderContacts_WorkorderId", table: "WorkOrderContacts", column: "WorkorderId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "workOrderAttachments"); migrationBuilder.DropTable( name: "workOrderCategories"); migrationBuilder.DropTable( name: "WorkOrderContacts"); migrationBuilder.DropColumn( name: "istemplate", table: "workOrders"); migrationBuilder.DropColumn( name: "Status", table: "Quotes"); migrationBuilder.AddColumn( name: "CategoryId", table: "workOrders", type: "int", nullable: true); migrationBuilder.AddColumn( name: "ContactId", table: "workOrders", type: "int", nullable: true); migrationBuilder.CreateIndex( name: "IX_workOrders_CategoryId", table: "workOrders", column: "CategoryId"); migrationBuilder.CreateIndex( name: "IX_workOrders_ContactId", table: "workOrders", column: "ContactId"); migrationBuilder.AddForeignKey( name: "FK_workOrders_Categories_CategoryId", table: "workOrders", column: "CategoryId", principalTable: "Categories", principalColumn: "Id", onDelete: ReferentialAction.Restrict); migrationBuilder.AddForeignKey( name: "FK_workOrders_Contacts_ContactId", table: "workOrders", column: "ContactId", principalTable: "Contacts", principalColumn: "Id", onDelete: ReferentialAction.Restrict); } } }