// PRODUCTION DEPLOY NOTE: additive-only (ADD COLUMN IF NOT EXISTS, no drops/truncates).
// Per CLAUDE.md Data Safety, apply to the live DB via SSH tunnel / docker exec BEFORE
// deploying the schema-dependent catalog code. Idempotent — safe to re-run.
// Run: npx tsx scripts/push-11b-fase-column.ts   (with DATABASE_URL pointing at the DB)
import postgres from "postgres";

async function push() {
  const databaseUrl = process.env.DATABASE_URL;
  if (!databaseUrl) {
    console.error("DATABASE_URL environment variable is required");
    process.exit(1);
  }

  const client = postgres(databaseUrl);

  try {
    console.log("Adding services.fase column...");
    await client`ALTER TABLE services ADD COLUMN IF NOT EXISTS fase text`;
    console.log("✓ services.fase column ready");
    process.exit(0);
  } catch (err: unknown) {
    console.error("Error pushing migration:", err instanceof Error ? err.message : err);
    process.exit(1);
  }
}

push();
