mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
Seed an organization-wide Area catalogue (East, Central, West, California) with stable ids, add a nullable AreaId to VendorCompany, allow only Admins to change it through the roster endpoints, expose areas facet metadata and an areas[n] company-directory filter with the __unassigned__ sentinel.
88 lines
3.2 KiB
C#
88 lines
3.2 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Data.SeaHavenIndustries.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class SH278_VendorCompanyArea : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "AreaId",
|
|
table: "VendorCompanies",
|
|
type: "int",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Areas",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<int>(type: "int", nullable: false)
|
|
.Annotation("SqlServer:Identity", "1, 1"),
|
|
Name = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
NormalizedName = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
|
|
IsActive = table.Column<bool>(type: "bit", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Areas", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_VendorCompanies_AreaId",
|
|
table: "VendorCompanies",
|
|
column: "AreaId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Areas_NormalizedName",
|
|
table: "Areas",
|
|
column: "NormalizedName",
|
|
unique: true);
|
|
|
|
// SH-278 v1 seed of the four dispatcher territories confirmed by Product.
|
|
// Names match the merged SH-273 Sites mapping (East / Central / West /
|
|
// California). Ids are stable; later renames change only the display name.
|
|
// Existing vendor companies stay Unassigned (no backfill).
|
|
migrationBuilder.InsertData(
|
|
table: "Areas",
|
|
columns: new[] { "Id", "Name", "NormalizedName", "IsActive" },
|
|
values: new object[,]
|
|
{
|
|
{ 1, "East", "east", true },
|
|
{ 2, "Central", "central", true },
|
|
{ 3, "West", "west", true },
|
|
{ 4, "California", "california", true }
|
|
});
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_VendorCompanies_Areas_AreaId",
|
|
table: "VendorCompanies",
|
|
column: "AreaId",
|
|
principalTable: "Areas",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Restrict);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_VendorCompanies_Areas_AreaId",
|
|
table: "VendorCompanies");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Areas");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_VendorCompanies_AreaId",
|
|
table: "VendorCompanies");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "AreaId",
|
|
table: "VendorCompanies");
|
|
}
|
|
}
|
|
}
|