82512eb1db
Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/gorbenko.pavel/tnsu-approval-route/pulls/13
63 lines
2.6 KiB
C#
63 lines
2.6 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 AddListPartitioning : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<DateTimeOffset>(
|
|
name: "list_partitioning_started_at",
|
|
table: "request_types",
|
|
type: "timestamp with time zone",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "request_list_partitions",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
request_type_id = table.Column<int>(type: "integer", nullable: false),
|
|
number = table.Column<int>(type: "integer", nullable: false),
|
|
list_id = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: false),
|
|
title = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
|
|
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk_request_list_partitions", x => x.id);
|
|
table.ForeignKey(
|
|
name: "fk_request_list_partitions_request_types_request_type_id",
|
|
column: x => x.request_type_id,
|
|
principalTable: "request_types",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "ix_request_list_partitions_request_type_id_number",
|
|
table: "request_list_partitions",
|
|
columns: new[] { "request_type_id", "number" },
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "request_list_partitions");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "list_partitioning_started_at",
|
|
table: "request_types");
|
|
}
|
|
}
|
|
}
|