import { defineConfig } from "drizzle-kit";

// drizzle-kit does not read `.env.local` the way Next.js does, so without this
// the fallback below would silently win — and on a machine where another
// project already owns port 5432, that means migrating the wrong database.
try {
  process.loadEnvFile(".env.local");
} catch {
  // No .env.local (CI, fresh clone): fall through to the environment as given.
}

export default defineConfig({
  schema: "./src/lib/schema/db.ts",
  out: "./drizzle",
  dialect: "postgresql",
  dbCredentials: {
    url:
      process.env.DATABASE_URL ||
      "postgresql://receipt_user:receipt_secure_password@localhost:5432/receipt_scanner",
  },
});
