import "dotenv/config";
import { AppDataSource } from "../data-source";

/** `pnpm --filter @edr/payment-api migration:revert` — undo the most recent migration. */
async function main(): Promise<void> {
  await AppDataSource.initialize();
  try {
    await AppDataSource.undoLastMigration();
    console.log("reverted last migration");
  } finally {
    await AppDataSource.destroy();
  }
}

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