2025-06-24 11:23:40 +03:00
|
|
|
import { drizzle } from "drizzle-orm/postgres-js";
|
|
|
|
|
import postgres from "postgres";
|
|
|
|
|
import * as schema from "./schema";
|
|
|
|
|
|
|
|
|
|
if (!process.env.DATABASE_URL) {
|
|
|
|
|
throw new Error("DATABASE_URL is not set");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Create the postgres client
|
|
|
|
|
const client = postgres(process.env.DATABASE_URL);
|
|
|
|
|
|
|
|
|
|
// Create the drizzle instance
|
|
|
|
|
export const db = drizzle(client, { schema });
|
|
|
|
|
|
|
|
|
|
// Re-export schema for convenience
|
2025-06-26 02:51:17 +02:00
|
|
|
export * from "./schema";
|
|
|
|
|
|
|
|
|
|
// Re-export drizzle-orm functions to ensure version consistency
|
|
|
|
|
export { eq, and, or, not, isNull, isNotNull, inArray, notInArray, exists, notExists, sql } from "drizzle-orm";
|