Initial commit
This commit is contained in:
@@ -0,0 +1,163 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PowderCoating.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddShopWorkers : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "AssignedWorkerId",
|
||||
table: "MaintenanceRecords",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "AssignedWorkerId",
|
||||
table: "Jobs",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopWorkers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Role = table.Column<int>(type: "int", nullable: false),
|
||||
Phone = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
||||
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
CompanyId = table.Column<int>(type: "int", nullable: false),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
UpdatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
|
||||
DeletedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
DeletedBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShopWorkers", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopWorkers_Companies_CompanyId",
|
||||
column: x => x.CompanyId,
|
||||
principalTable: "Companies",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "PricingTiers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 1,
|
||||
column: "CreatedAt",
|
||||
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5718));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "PricingTiers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 2,
|
||||
column: "CreatedAt",
|
||||
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5725));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "PricingTiers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 3,
|
||||
column: "CreatedAt",
|
||||
value: new DateTime(2026, 2, 7, 20, 6, 23, 60, DateTimeKind.Utc).AddTicks(5728));
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_MaintenanceRecords_AssignedWorkerId",
|
||||
table: "MaintenanceRecords",
|
||||
column: "AssignedWorkerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Jobs_AssignedWorkerId",
|
||||
table: "Jobs",
|
||||
column: "AssignedWorkerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopWorkers_CompanyId",
|
||||
table: "ShopWorkers",
|
||||
column: "CompanyId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Jobs_ShopWorkers_AssignedWorkerId",
|
||||
table: "Jobs",
|
||||
column: "AssignedWorkerId",
|
||||
principalTable: "ShopWorkers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_MaintenanceRecords_ShopWorkers_AssignedWorkerId",
|
||||
table: "MaintenanceRecords",
|
||||
column: "AssignedWorkerId",
|
||||
principalTable: "ShopWorkers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.SetNull);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Jobs_ShopWorkers_AssignedWorkerId",
|
||||
table: "Jobs");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_MaintenanceRecords_ShopWorkers_AssignedWorkerId",
|
||||
table: "MaintenanceRecords");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopWorkers");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_MaintenanceRecords_AssignedWorkerId",
|
||||
table: "MaintenanceRecords");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Jobs_AssignedWorkerId",
|
||||
table: "Jobs");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AssignedWorkerId",
|
||||
table: "MaintenanceRecords");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AssignedWorkerId",
|
||||
table: "Jobs");
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "PricingTiers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 1,
|
||||
column: "CreatedAt",
|
||||
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5847));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "PricingTiers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 2,
|
||||
column: "CreatedAt",
|
||||
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5851));
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "PricingTiers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 3,
|
||||
column: "CreatedAt",
|
||||
value: new DateTime(2026, 2, 7, 15, 35, 42, 945, DateTimeKind.Utc).AddTicks(5853));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user