using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace AsbCloudDb.Migrations { public partial class Add_DrillingProgram_parts : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "t_drilling_program_part", columns: table => new { id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), id_well = table.Column(type: "integer", nullable: false), id_file_category = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_t_drilling_program_part", x => x.id); table.ForeignKey( name: "FK_t_drilling_program_part_t_file_category_id_file_category", column: x => x.id_file_category, principalTable: "t_file_category", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_t_drilling_program_part_t_well_id_well", column: x => x.id_well, principalTable: "t_well", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "части программ бурения"); migrationBuilder.CreateTable( name: "t_relation_user_drilling_program_part", columns: table => new { id_user = table.Column(type: "integer", nullable: false), id_drilling_program_part = table.Column(type: "integer", nullable: false), id_role = table.Column(type: "integer", nullable: false, comment: "1 - publisher, 2 - approver") }, constraints: table => { table.PrimaryKey("t_relation_user_drilling_program_part_pk", x => new { x.id_user, x.id_drilling_program_part }); table.ForeignKey( name: "FK_t_relation_user_drilling_program_part_t_drilling_program_pa~", column: x => x.id_drilling_program_part, principalTable: "t_drilling_program_part", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_t_relation_user_drilling_program_part_t_user_id_user", column: x => x.id_user, principalTable: "t_user", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "Отношение пользователей и частей ПБ"); migrationBuilder.CreateIndex( name: "IX_t_drilling_program_part_id_file_category", table: "t_drilling_program_part", column: "id_file_category"); migrationBuilder.CreateIndex( name: "IX_t_drilling_program_part_id_well", table: "t_drilling_program_part", column: "id_well"); migrationBuilder.CreateIndex( name: "IX_t_relation_user_drilling_program_part_id_drilling_program_p~", table: "t_relation_user_drilling_program_part", column: "id_drilling_program_part"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "t_relation_user_drilling_program_part"); migrationBuilder.DropTable( name: "t_drilling_program_part"); } } }