using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace BigRegister.Api.Data.Migrations
{
  /// <inheritdoc />
  public partial class OrgTemplates : Migration
  {
    /// <inheritdoc />
    protected override void Up(MigrationBuilder migrationBuilder)
    {
      migrationBuilder.AddColumn<int>(
          name: "SentOrgTemplateVersion",
          table: "Briefs",
          type: "INTEGER",
          nullable: true);

      migrationBuilder.AddColumn<string>(
          name: "SubOrgId",
          table: "Briefs",
          type: "TEXT",
          nullable: false,
          // Briefs from before this migration adopt the seeded default sub-org.
          defaultValue: "cibg-registers");

      migrationBuilder.CreateTable(
          name: "OrgTemplates",
          columns: table => new
          {
            SubOrgId = table.Column<string>(type: "TEXT", nullable: false),
            Draft = table.Column<string>(type: "TEXT", nullable: false),
            PublishedVersion = table.Column<int>(type: "INTEGER", nullable: false),
            History = table.Column<string>(type: "TEXT", nullable: false)
          },
          constraints: table =>
          {
            table.PrimaryKey("PK_OrgTemplates", x => x.SubOrgId);
          });
    }

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

      migrationBuilder.DropColumn(
          name: "SentOrgTemplateVersion",
          table: "Briefs");

      migrationBuilder.DropColumn(
          name: "SubOrgId",
          table: "Briefs");
    }
  }
}
