From 356b12d9a18d068e165ee46f45a5e7127eb4a1f2 Mon Sep 17 00:00:00 2001 From: ngfrolov Date: Tue, 5 Dec 2023 11:31:02 +0500 Subject: [PATCH] fix Daily report migration --- ...31205060749_Daily_report_lost_migration.cs | 248 ------------------ ...4_Daily_report_lost_migration.Designer.cs} | 2 +- ...31205062914_Daily_report_lost_migration.cs | 35 +++ 3 files changed, 36 insertions(+), 249 deletions(-) delete mode 100644 AsbCloudDb/Migrations/20231205060749_Daily_report_lost_migration.cs rename AsbCloudDb/Migrations/{20231205060749_Daily_report_lost_migration.Designer.cs => 20231205062914_Daily_report_lost_migration.Designer.cs} (99%) create mode 100644 AsbCloudDb/Migrations/20231205062914_Daily_report_lost_migration.cs diff --git a/AsbCloudDb/Migrations/20231205060749_Daily_report_lost_migration.cs b/AsbCloudDb/Migrations/20231205060749_Daily_report_lost_migration.cs deleted file mode 100644 index 36e4e49f..00000000 --- a/AsbCloudDb/Migrations/20231205060749_Daily_report_lost_migration.cs +++ /dev/null @@ -1,248 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace AsbCloudDb.Migrations -{ - public partial class Daily_report_lost_migration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "DailyReport"); - - migrationBuilder.DropPrimaryKey( - name: "t_id_well_date_start_pk", - table: "t_daily_report"); - - migrationBuilder.DropColumn( - name: "start_date", - table: "t_daily_report"); - - migrationBuilder.DropColumn( - name: "info", - table: "t_daily_report"); - - migrationBuilder.AddColumn( - name: "Id", - table: "t_daily_report", - type: "integer", - nullable: false, - defaultValue: 0) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn); - - migrationBuilder.AddColumn( - name: "date", - table: "t_daily_report", - type: "timestamp with time zone", - nullable: false, - defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - comment: "Дата формирования отчёта"); - - migrationBuilder.AddColumn( - name: "date_last_update", - table: "t_daily_report", - type: "timestamp with time zone", - nullable: true, - comment: "Дата последнего обновления"); - - migrationBuilder.AddColumn( - name: "sign_block", - table: "t_daily_report", - type: "jsonb", - nullable: true, - comment: "Подпись"); - - migrationBuilder.AddColumn( - name: "subsystem_block", - table: "t_daily_report", - type: "jsonb", - nullable: true, - comment: "Наработкой подсистем"); - - migrationBuilder.AddColumn( - name: "time_balance_block", - table: "t_daily_report", - type: "jsonb", - nullable: true, - comment: "Баланс времени"); - - migrationBuilder.AddPrimaryKey( - name: "PK_t_daily_report", - table: "t_daily_report", - column: "Id"); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 1, - column: "is_contact", - value: true); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 2, - column: "is_contact", - value: true); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 3, - column: "is_contact", - value: true); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 7, - column: "is_contact", - value: false); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 12, - column: "order", - value: 8); - - migrationBuilder.InsertData( - table: "t_company_type", - columns: new[] { "id", "caption", "is_contact", "order" }, - values: new object[] { 11, "Дизельный сервис", false, 9 }); - - migrationBuilder.CreateIndex( - name: "IX_t_daily_report_id_well_date", - table: "t_daily_report", - columns: new[] { "id_well", "date" }, - unique: true); - - migrationBuilder.AddForeignKey( - name: "FK_t_daily_report_t_well_id_well", - table: "t_daily_report", - column: "id_well", - principalTable: "t_well", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_t_daily_report_t_well_id_well", - table: "t_daily_report"); - - migrationBuilder.DropPrimaryKey( - name: "PK_t_daily_report", - table: "t_daily_report"); - - migrationBuilder.DropIndex( - name: "IX_t_daily_report_id_well_date", - table: "t_daily_report"); - - migrationBuilder.DeleteData( - table: "t_company_type", - keyColumn: "id", - keyValue: 11); - - migrationBuilder.DropColumn( - name: "Id", - table: "t_daily_report"); - - migrationBuilder.DropColumn( - name: "date", - table: "t_daily_report"); - - migrationBuilder.DropColumn( - name: "date_last_update", - table: "t_daily_report"); - - migrationBuilder.DropColumn( - name: "sign_block", - table: "t_daily_report"); - - migrationBuilder.DropColumn( - name: "subsystem_block", - table: "t_daily_report"); - - migrationBuilder.DropColumn( - name: "time_balance_block", - table: "t_daily_report"); - - migrationBuilder.AddColumn( - name: "start_date", - table: "t_daily_report", - type: "date", - nullable: false, - defaultValue: new DateOnly(1, 1, 1), - comment: "Дата отчёта"); - - migrationBuilder.AddColumn( - name: "info", - table: "t_daily_report", - type: "jsonb", - nullable: false, - defaultValue: "", - comment: "Список параметров для отчёта"); - - migrationBuilder.AddPrimaryKey( - name: "t_id_well_date_start_pk", - table: "t_daily_report", - columns: new[] { "id_well", "start_date" }); - - migrationBuilder.CreateTable( - name: "DailyReport", - columns: table => new - { - IdWell = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.ForeignKey( - name: "FK_DailyReport_t_well_IdWell", - column: x => x.IdWell, - principalTable: "t_well", - principalColumn: "id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 1, - column: "is_contact", - value: false); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 2, - column: "is_contact", - value: false); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 3, - column: "is_contact", - value: false); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 7, - column: "is_contact", - value: true); - - migrationBuilder.UpdateData( - table: "t_company_type", - keyColumn: "id", - keyValue: 12, - column: "order", - value: 7); - } - } -} diff --git a/AsbCloudDb/Migrations/20231205060749_Daily_report_lost_migration.Designer.cs b/AsbCloudDb/Migrations/20231205062914_Daily_report_lost_migration.Designer.cs similarity index 99% rename from AsbCloudDb/Migrations/20231205060749_Daily_report_lost_migration.Designer.cs rename to AsbCloudDb/Migrations/20231205062914_Daily_report_lost_migration.Designer.cs index 978f20ac..fd4ff53b 100644 --- a/AsbCloudDb/Migrations/20231205060749_Daily_report_lost_migration.Designer.cs +++ b/AsbCloudDb/Migrations/20231205062914_Daily_report_lost_migration.Designer.cs @@ -13,7 +13,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace AsbCloudDb.Migrations { [DbContext(typeof(AsbCloudDbContext))] - [Migration("20231205060749_Daily_report_lost_migration")] + [Migration("20231205062914_Daily_report_lost_migration")] partial class Daily_report_lost_migration { protected override void BuildTargetModel(ModelBuilder modelBuilder) diff --git a/AsbCloudDb/Migrations/20231205062914_Daily_report_lost_migration.cs b/AsbCloudDb/Migrations/20231205062914_Daily_report_lost_migration.cs new file mode 100644 index 00000000..ec314216 --- /dev/null +++ b/AsbCloudDb/Migrations/20231205062914_Daily_report_lost_migration.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace AsbCloudDb.Migrations +{ + public partial class Daily_report_lost_migration : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DeleteData( + table: "t_relation_user_role_permission", + keyColumns: new[] { "id_permission", "id_user_role" }, + keyValues: new object[] { 529, 1 }); + + migrationBuilder.DeleteData( + table: "t_permission", + keyColumn: "id", + keyValue: 529); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.InsertData( + table: "t_permission", + columns: new[] { "id", "description", "name" }, + values: new object[] { 529, "Разрешение редактировать фактические траектории", "FactTrajectory.edit" }); + + migrationBuilder.InsertData( + table: "t_relation_user_role_permission", + columns: new[] { "id_permission", "id_user_role" }, + values: new object[] { 529, 1 }); + } + } +}