import { defineConfig } from "drizzle-kit";

const databaseType = process.env.DATABASE_TYPE || "sqlite";
const databaseUrl = process.env.DATABASE_URL;

export default defineConfig({
  schema: "./src/database/schema.ts",
  out: "./drizzle/migrations",
  dialect: databaseType === "postgres" ? "postgresql" : "sqlite",
  dbCredentials:
    databaseType === "postgres"
      ? databaseUrl
        ? { url: databaseUrl }
        : {
            host: process.env.POSTGRES_HOST || "localhost",
            port: parseInt(process.env.POSTGRES_PORT || "5432", 10),
            user: process.env.POSTGRES_USER || "postgres",
            password: process.env.POSTGRES_PASSWORD || "",
            database: process.env.POSTGRES_DB || "moderation_bot",
          }
      : {
          url: "file:./.muxer-queue.db",
        },
});
