105 lines
5.0 KiB
C#
105 lines
5.0 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialCreate : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "request_types",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: false),
|
|
page_url = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_request_types", x => x.id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "template_routes",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
route_type = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
|
request_type_id = table.Column<int>(type: "integer", nullable: false),
|
|
department_id = table.Column<Guid>(type: "uuid", nullable: true),
|
|
company_id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
by_project = table.Column<bool>(type: "boolean", nullable: false),
|
|
requires_control = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_template_routes", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_template_routes_request_types_request_type_id",
|
|
column: x => x.request_type_id,
|
|
principalTable: "request_types",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "template_route_steps",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
order_no = table.Column<int>(type: "integer", nullable: false),
|
|
executor_email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
|
position = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
|
project_role = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
|
head_type = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
|
status = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
|
|
route_id = table.Column<int>(type: "integer", nullable: false),
|
|
allow_reassign_to_other_approvers = table.Column<bool>(type: "boolean", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_template_route_steps", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_template_route_steps_template_routes_route_id",
|
|
column: x => x.route_id,
|
|
principalTable: "template_routes",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_template_route_steps_route_id_order_no",
|
|
table: "template_route_steps",
|
|
columns: new[] { "route_id", "order_no" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_template_routes_request_type_id_department_id_company_id_by",
|
|
table: "template_routes",
|
|
columns: new[] { "request_type_id", "department_id", "company_id", "by_project" },
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "template_route_steps");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "template_routes");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "request_types");
|
|
}
|
|
}
|
|
}
|