using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Meezi.Infrastructure.Data.Migrations
{
    /// <inheritdoc />
    public partial class FixOrderItemVoidColumns : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            // VoidOrderLine (20260521134834) was recorded but its Up() was empty on some databases.
            migrationBuilder.Sql(
                """
                ALTER TABLE "OrderItems" ADD COLUMN IF NOT EXISTS "IsVoided" boolean NOT NULL DEFAULT false;
                ALTER TABLE "OrderItems" ADD COLUMN IF NOT EXISTS "VoidedAt" timestamp with time zone;
                ALTER TABLE "OrderItems" ADD COLUMN IF NOT EXISTS "VoidedByUserId" text;
                """);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql(
                """
                ALTER TABLE "OrderItems" DROP COLUMN IF EXISTS "VoidedByUserId";
                ALTER TABLE "OrderItems" DROP COLUMN IF EXISTS "VoidedAt";
                ALTER TABLE "OrderItems" DROP COLUMN IF EXISTS "IsVoided";
                """);
        }
    }
}
