using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace DiunaBI.Infrastructure.Migrations
{
    /// <inheritdoc />
    public partial class QueueJobRefactor : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "Message",
                table: "QueueJobs");

            migrationBuilder.RenameColumn(
                name: "Type",
                table: "QueueJobs",
                newName: "RetryCount");

            migrationBuilder.RenameColumn(
                name: "ModifiedAt",
                table: "QueueJobs",
                newName: "ModifiedAtUtc");

            migrationBuilder.RenameColumn(
                name: "Attempts",
                table: "QueueJobs",
                newName: "Priority");

            migrationBuilder.AddColumn<DateTime>(
                name: "CompletedAt",
                table: "QueueJobs",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AddColumn<DateTime>(
                name: "CreatedAtUtc",
                table: "QueueJobs",
                type: "datetime2",
                nullable: false,
                defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));

            migrationBuilder.AddColumn<Guid>(
                name: "CreatedById",
                table: "QueueJobs",
                type: "uniqueidentifier",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AddColumn<int>(
                name: "JobType",
                table: "QueueJobs",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<DateTime>(
                name: "LastAttemptAt",
                table: "QueueJobs",
                type: "datetime2",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "LastError",
                table: "QueueJobs",
                type: "nvarchar(1000)",
                maxLength: 1000,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "LayerName",
                table: "QueueJobs",
                type: "nvarchar(200)",
                maxLength: 200,
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<int>(
                name: "MaxRetries",
                table: "QueueJobs",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<Guid>(
                name: "ModifiedById",
                table: "QueueJobs",
                type: "uniqueidentifier",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AddColumn<string>(
                name: "PluginName",
                table: "QueueJobs",
                type: "nvarchar(100)",
                maxLength: 100,
                nullable: false,
                defaultValue: "");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "CompletedAt",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "CreatedAtUtc",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "CreatedById",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "JobType",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "LastAttemptAt",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "LastError",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "LayerName",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "MaxRetries",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "ModifiedById",
                table: "QueueJobs");

            migrationBuilder.DropColumn(
                name: "PluginName",
                table: "QueueJobs");

            migrationBuilder.RenameColumn(
                name: "RetryCount",
                table: "QueueJobs",
                newName: "Type");

            migrationBuilder.RenameColumn(
                name: "Priority",
                table: "QueueJobs",
                newName: "Attempts");

            migrationBuilder.RenameColumn(
                name: "ModifiedAtUtc",
                table: "QueueJobs",
                newName: "ModifiedAt");

            migrationBuilder.AddColumn<string>(
                name: "Message",
                table: "QueueJobs",
                type: "nvarchar(max)",
                nullable: false,
                defaultValue: "");
        }
    }
}
