Ctrl K
ComunidadGuías…

drizzle.config.ts

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
/**
 * drizzle.config.ts
 *
 * Configures Drizzle Kit - the migration generator + studio + introspection CLI.
 *
 * Migrations are SQL files in `drizzle/`, generated by `npm run db:generate` after a
 * schema change, reviewed by a human, then applied at app-container boot (ADR-0011,
 * which superseded the earlier explicit-apply decision in ADR-0005).
 *
 * This config is the POSTGRES dialect. SQLite has its own config + migration history
 * (`drizzle.sqlite.config.ts` → `drizzle-sqlite/`); the two dialects never share a
 * migration file. Always regenerate BOTH after a schema change.
 */

import { defineConfig } from "drizzle-kit";

// We can't import `lib/env.ts` here because drizzle-kit runs outside the app runtime
// and would pull in Next.js machinery it can't satisfy. Use process.env directly with
// a clear error if DATABASE_URL is missing.
const databaseUrl = process.env["DATABASE_URL"];
if (!databaseUrl) {
  throw new Error("DATABASE_URL is required. Copy .env.example to .env.local and set it.");
}

export default defineConfig({
  schema: "./lib/db/schema/index.ts",
  out: "./drizzle",
  dialect: "postgresql",
  dbCredentials: { url: databaseUrl },
  // Verbose migration output - at this stage every migration is reviewed by a human and
  // verbose helps catch mistakes early.
  verbose: true,
  strict: true,
});