using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace AsbCloudDb.Migrations
{
    public partial class Enable_nullable_on_telemetry_ : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql("update t_telemetry set timezone = '{\"Hours\": 5}' where timezone is null;");
            migrationBuilder.Sql("update t_telemetry set info = '{}' where info is null;");

            migrationBuilder.AlterColumn<string>(
                name: "surname",
                table: "t_telemetry_user",
                type: "character varying(255)",
                maxLength: 255,
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "character varying(255)",
                oldMaxLength: 255,
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "message_template",
                table: "t_telemetry_event",
                type: "text",
                nullable: false,
                defaultValue: "",
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true);

            migrationBuilder.AlterColumn<string>(
                name: "timezone",
                table: "t_telemetry",
                type: "jsonb",
                nullable: false,
                defaultValue: "{\"Hours\": 5}",
                comment: "Смещение часового пояса от UTC",
                oldClrType: typeof(string),
                oldType: "jsonb",
                oldNullable: true,
                oldComment: "Смещение часового пояса от UTC");

            migrationBuilder.AlterColumn<string>(
                name: "remote_uid",
                table: "t_telemetry",
                type: "text",
                nullable: false,
                defaultValue: "",
                comment: "Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.",
                oldClrType: typeof(string),
                oldType: "text",
                oldNullable: true,
                oldComment: "Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");

            migrationBuilder.AlterColumn<string>(
                name: "info",
                table: "t_telemetry",
                type: "jsonb",
                nullable: false,
                defaultValue: "{}",
                comment: "Информация с панели о скважине",
                oldClrType: typeof(string),
                oldType: "jsonb",
                oldNullable: true,
                oldComment: "Информация с панели о скважине");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<string>(
                name: "surname",
                table: "t_telemetry_user",
                type: "character varying(255)",
                maxLength: 255,
                nullable: true,
                oldClrType: typeof(string),
                oldType: "character varying(255)",
                oldMaxLength: 255);

            migrationBuilder.AlterColumn<string>(
                name: "message_template",
                table: "t_telemetry_event",
                type: "text",
                nullable: true,
                oldClrType: typeof(string),
                oldType: "text");

            migrationBuilder.AlterColumn<string>(
                name: "timezone",
                table: "t_telemetry",
                type: "jsonb",
                nullable: true,
                comment: "Смещение часового пояса от UTC",
                oldClrType: typeof(string),
                oldType: "jsonb",
                oldComment: "Смещение часового пояса от UTC");

            migrationBuilder.AlterColumn<string>(
                name: "remote_uid",
                table: "t_telemetry",
                type: "text",
                nullable: true,
                comment: "Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.",
                oldClrType: typeof(string),
                oldType: "text",
                oldComment: "Идентификатор передающего устройства. Может повторяться в списке, так как комплекты оборудования переезжают от скв. к скв.");

            migrationBuilder.AlterColumn<string>(
                name: "info",
                table: "t_telemetry",
                type: "jsonb",
                nullable: true,
                comment: "Информация с панели о скважине",
                oldClrType: typeof(string),
                oldType: "jsonb",
                oldComment: "Информация с панели о скважине");
        }
    }
}