import { defineConfig } from "drizzle-kit"

/**
 * PostgreSQL, decided in `machine/decisions.json` (`postgres-docker`). The MVP
 * ran SQLite; none of its notes transfer.
 *
 * `generate` reads the schema and writes SQL without opening a connection, so
 * the migration can be produced and reviewed on a machine that has no database.
 * `DATABASE_URL` is only needed by `migrate`, `push` and `studio`.
 */
export default defineConfig({
  dialect: "postgresql",
  // Two files, because Better Auth's four tables are generated by its own CLI
  // and overwritten whenever a plugin changes. Keeping them apart means a
  // regeneration cannot take our tables with it.
  schema: ["./lib/db/schema.ts", "./lib/db/auth-schema.ts"],
  out: "./drizzle",
  dbCredentials: {
    url: process.env.DATABASE_URL ?? "",
  },
})
