using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BigRegister.Api.Data.Migrations
{
  /// <inheritdoc />
  public partial class Initial : Migration
  {
    /// <inheritdoc />
    protected override void Up(MigrationBuilder migrationBuilder)
    {
      migrationBuilder.CreateTable(
          name: "Applications",
          columns: table => new
          {
            Id = table.Column<string>(type: "TEXT", nullable: false),
            Type = table.Column<string>(type: "TEXT", nullable: false),
            Owner = table.Column<string>(type: "TEXT", nullable: false),
            Draft = table.Column<string>(type: "TEXT", nullable: true),
            StepIndex = table.Column<int>(type: "INTEGER", nullable: false),
            StepCount = table.Column<int>(type: "INTEGER", nullable: false),
            DocumentIds = table.Column<string>(type: "TEXT", nullable: false),
            Referentie = table.Column<string>(type: "TEXT", nullable: true),
            AutoApprovable = table.Column<bool>(type: "INTEGER", nullable: false),
            Reden = table.Column<string>(type: "TEXT", nullable: true),
            Submitted = table.Column<bool>(type: "INTEGER", nullable: false),
            CreatedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
            UpdatedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
            SubmittedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: true)
          },
          constraints: table =>
          {
            table.PrimaryKey("PK_Applications", x => x.Id);
          });

      migrationBuilder.CreateTable(
          name: "AuditEntries",
          columns: table => new
          {
            Id = table.Column<long>(type: "INTEGER", nullable: false)
                  .Annotation("Sqlite:Autoincrement", true),
            At = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
            Action = table.Column<string>(type: "TEXT", nullable: false),
            DocumentId = table.Column<string>(type: "TEXT", nullable: false),
            CategoryId = table.Column<string>(type: "TEXT", nullable: false),
            Actor = table.Column<string>(type: "TEXT", nullable: false)
          },
          constraints: table =>
          {
            table.PrimaryKey("PK_AuditEntries", x => x.Id);
          });

      migrationBuilder.CreateTable(
          name: "Briefs",
          columns: table => new
          {
            BriefId = table.Column<string>(type: "TEXT", nullable: false),
            Owner = table.Column<string>(type: "TEXT", nullable: false),
            Beroep = table.Column<string>(type: "TEXT", nullable: false),
            TemplateId = table.Column<string>(type: "TEXT", nullable: false),
            DrafterId = table.Column<string>(type: "TEXT", nullable: false),
            Placeholders = table.Column<string>(type: "TEXT", nullable: false),
            Sections = table.Column<string>(type: "TEXT", nullable: false),
            Status = table.Column<string>(type: "TEXT", nullable: false)
          },
          constraints: table =>
          {
            table.PrimaryKey("PK_Briefs", x => x.BriefId);
          });

      migrationBuilder.CreateTable(
          name: "Documents",
          columns: table => new
          {
            DocumentId = table.Column<string>(type: "TEXT", nullable: false),
            LocalId = table.Column<string>(type: "TEXT", nullable: false),
            CategoryId = table.Column<string>(type: "TEXT", nullable: false),
            WizardId = table.Column<string>(type: "TEXT", nullable: false),
            FileName = table.Column<string>(type: "TEXT", nullable: false),
            SizeBytes = table.Column<long>(type: "INTEGER", nullable: false),
            ContentType = table.Column<string>(type: "TEXT", nullable: false),
            Content = table.Column<byte[]>(type: "BLOB", nullable: false),
            Owner = table.Column<string>(type: "TEXT", nullable: false),
            UploadedAt = table.Column<DateTimeOffset>(type: "TEXT", nullable: false),
            Linked = table.Column<bool>(type: "INTEGER", nullable: false)
          },
          constraints: table =>
          {
            table.PrimaryKey("PK_Documents", x => x.DocumentId);
          });

      migrationBuilder.CreateIndex(
          name: "IX_Briefs_Owner",
          table: "Briefs",
          column: "Owner",
          unique: true);
    }

    /// <inheritdoc />
    protected override void Down(MigrationBuilder migrationBuilder)
    {
      migrationBuilder.DropTable(
          name: "Applications");

      migrationBuilder.DropTable(
          name: "AuditEntries");

      migrationBuilder.DropTable(
          name: "Briefs");

      migrationBuilder.DropTable(
          name: "Documents");
    }
  }
}
