20260106071718_Migration_20260106151700.cs 3.68 KB
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Rcs.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class Migration_20260106151700 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "storage_areas",
                columns: table => new
                {
                    area_id = table.Column<Guid>(type: "uuid", nullable: false),
                    area_code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    area_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    description = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
                    is_active = table.Column<bool>(type: "boolean", nullable: false),
                    created_at = table.Column<DateTime>(type: "timestamp", nullable: false),
                    updated_at = table.Column<DateTime>(type: "timestamp", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_storage_areas", x => x.area_id);
                });

            migrationBuilder.CreateTable(
                name: "storage_locations",
                columns: table => new
                {
                    location_id = table.Column<Guid>(type: "uuid", nullable: false),
                    area_id = table.Column<Guid>(type: "uuid", nullable: false),
                    map_node_id = table.Column<Guid>(type: "uuid", nullable: true),
                    location_code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    location_name = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: true),
                    status = table.Column<int>(type: "integer", nullable: false),
                    is_active = table.Column<bool>(type: "boolean", nullable: false),
                    created_at = table.Column<DateTime>(type: "timestamp", nullable: false),
                    updated_at = table.Column<DateTime>(type: "timestamp", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_storage_locations", x => x.location_id);
                    table.ForeignKey(
                        name: "FK_storage_locations_map_nodes_map_node_id",
                        column: x => x.map_node_id,
                        principalTable: "map_nodes",
                        principalColumn: "node_id");
                    table.ForeignKey(
                        name: "FK_storage_locations_storage_areas_area_id",
                        column: x => x.area_id,
                        principalTable: "storage_areas",
                        principalColumn: "area_id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_storage_locations_area_id",
                table: "storage_locations",
                column: "area_id");

            migrationBuilder.CreateIndex(
                name: "IX_storage_locations_map_node_id",
                table: "storage_locations",
                column: "map_node_id");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "storage_locations");

            migrationBuilder.DropTable(
                name: "storage_areas");
        }
    }
}