import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import * as schema from './schema';

const DATABASE_URL = process.env.DATABASE_URL || 'postgresql://jakeshore@localhost:5432/goosefactory';

// Connection for queries
const queryClient = postgres(DATABASE_URL);

// Drizzle instance with schema for relational queries
export const db = drizzle(queryClient, { schema });

// Export for migration runner
export const migrationClient = postgres(DATABASE_URL, { max: 1 });

export type Database = typeof db;
