92 lines
3.6 KiB
C#
92 lines
3.6 KiB
C#
using System;
|
||
using Microsoft.EntityFrameworkCore.Migrations;
|
||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||
|
||
#nullable disable
|
||
|
||
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||
|
||
namespace PARR.DAL.Migrations
|
||
{
|
||
/// <inheritdoc />
|
||
public partial class TblOrdersAndStatus : Migration
|
||
{
|
||
/// <inheritdoc />
|
||
protected override void Up(MigrationBuilder migrationBuilder)
|
||
{
|
||
migrationBuilder.CreateTable(
|
||
name: "OrderStatuses",
|
||
columns: table => new
|
||
{
|
||
Code = table.Column<int>(type: "integer", nullable: false)
|
||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||
Name = table.Column<string>(type: "text", nullable: false),
|
||
Description = table.Column<string>(type: "text", nullable: false)
|
||
},
|
||
constraints: table =>
|
||
{
|
||
table.PrimaryKey("PK_OrderStatuses", x => x.Code);
|
||
});
|
||
|
||
migrationBuilder.CreateTable(
|
||
name: "Orders",
|
||
columns: table => new
|
||
{
|
||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||
Number = table.Column<string>(type: "text", nullable: false),
|
||
WorkGroup = table.Column<string>(type: "text", nullable: true),
|
||
TemplateId = table.Column<Guid>(type: "uuid", nullable: true),
|
||
OrderStatusCode = table.Column<int>(type: "integer", nullable: false)
|
||
},
|
||
constraints: table =>
|
||
{
|
||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||
table.ForeignKey(
|
||
name: "FK_Orders_OrderStatuses_OrderStatusCode",
|
||
column: x => x.OrderStatusCode,
|
||
principalTable: "OrderStatuses",
|
||
principalColumn: "Code",
|
||
onDelete: ReferentialAction.Cascade);
|
||
table.ForeignKey(
|
||
name: "FK_Orders_Templates_TemplateId",
|
||
column: x => x.TemplateId,
|
||
principalTable: "Templates",
|
||
principalColumn: "Id");
|
||
});
|
||
|
||
migrationBuilder.InsertData(
|
||
table: "OrderStatuses",
|
||
columns: new[] { "Code", "Description", "Name" },
|
||
values: new object[,]
|
||
{
|
||
{ 1, "1-Направлен в группу", "New" },
|
||
{ 2, "2-В работе", "InWork" },
|
||
{ 3, "3-Приостановлен", "Stop" },
|
||
{ 4, "4-Выполнен", "Complete" },
|
||
{ 5, "5-Закрыт", "Closed" }
|
||
});
|
||
|
||
migrationBuilder.CreateIndex(
|
||
name: "IX_Orders_OrderStatusCode",
|
||
table: "Orders",
|
||
column: "OrderStatusCode");
|
||
|
||
migrationBuilder.CreateIndex(
|
||
name: "IX_Orders_TemplateId",
|
||
table: "Orders",
|
||
column: "TemplateId");
|
||
}
|
||
|
||
/// <inheritdoc />
|
||
protected override void Down(MigrationBuilder migrationBuilder)
|
||
{
|
||
migrationBuilder.DropTable(
|
||
name: "Orders");
|
||
|
||
migrationBuilder.DropTable(
|
||
name: "OrderStatuses");
|
||
}
|
||
}
|
||
}
|