mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
240 lines
10 KiB
C#
240 lines
10 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Data.SeaHavenIndustries.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class dropdowntablechange : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
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<bool>(
|
|
name: "istemplate",
|
|
table: "workOrders",
|
|
type: "bit",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Status",
|
|
table: "Quotes",
|
|
type: "nvarchar(max)",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "workOrderAttachments",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Attachments = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
WorkorderId = table.Column<int>(type: "int", nullable: true),
|
|
ContactsId = table.Column<int>(type: "int", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
|
|
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModifierUserId = table.Column<int>(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<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
CategoryId = table.Column<int>(type: "int", nullable: true),
|
|
WorkorderId = table.Column<int>(type: "int", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
|
|
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModifierUserId = table.Column<int>(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<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
ContactId = table.Column<int>(type: "int", nullable: true),
|
|
WorkorderId = table.Column<int>(type: "int", nullable: true),
|
|
IsDeleted = table.Column<bool>(type: "bit", nullable: true),
|
|
createdby = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
DeleterUserId = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
|
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
CreatedDate = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
|
|
LastModifierUserId = table.Column<int>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
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<int>(
|
|
name: "CategoryId",
|
|
table: "workOrders",
|
|
type: "int",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
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);
|
|
}
|
|
}
|
|
}
|