import { applyMigrationFile, withMigrationClient } from "./sql-migration-runtime.js";

async function main() {
  const inputPath = process.argv[2];
  if (!inputPath) {
    throw new Error(
      "No SQL migration file provided. Pass an explicit path, for example: pnpm -C lib/db exec tsx src/apply-sql-migration.ts lib/db/migrations/20260713_organization_susu_phase5.sql",
    );
  }

  await withMigrationClient((client) => applyMigrationFile(client, inputPath));
}

main().catch((err) => {
  console.error(err);
  process.exitCode = 1;
});
