using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AsbCloudDb.Migrations
{
    public partial class DetectedOperation_add_subsystems_and_extraData : 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);

            migrationBuilder.DropColumn(
                name: "id_reason_of_end",
                table: "t_detected_operation");

            migrationBuilder.AddColumn<int>(
                name: "enabled_subsystems",
                table: "t_detected_operation",
                type: "integer",
                nullable: false,
                defaultValue: 0,
                comment: "флаги аключенных подсистем");

            migrationBuilder.AddColumn<IDictionary<string, object>>(
                name: "extra_data",
                table: "t_detected_operation",
                type: "jsonb",
                nullable: false,
                defaultValue: new { },
                comment: "доп. инфо по операции");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "enabled_subsystems",
                table: "t_detected_operation");

            migrationBuilder.DropColumn(
                name: "extra_data",
                table: "t_detected_operation");

            migrationBuilder.AddColumn<int>(
                name: "id_reason_of_end",
                table: "t_detected_operation",
                type: "integer",
                nullable: false,
                defaultValue: 0,
                comment: "Код признака окончания операции");

            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 });
        }
    }
}