using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "request_types", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), page_url = table.Column(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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), route_type = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), request_type_id = table.Column(type: "integer", nullable: false), department_id = table.Column(type: "uuid", nullable: true), company_id = table.Column(type: "uuid", nullable: false), by_project = table.Column(type: "boolean", nullable: false), requires_control = table.Column(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(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), order_no = table.Column(type: "integer", nullable: false), executor_email = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), position = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), project_role = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), head_type = table.Column(type: "character varying(32)", maxLength: 32, nullable: true), status = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), route_id = table.Column(type: "integer", nullable: false), allow_reassign_to_other_approvers = table.Column(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); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "template_route_steps"); migrationBuilder.DropTable( name: "template_routes"); migrationBuilder.DropTable( name: "request_types"); } } }