export type Dialect = 'sqlite' | 'pg' | 'mysql'

export function getDialect(): Dialect {
  const d = (process.env.DB_DIALECT?.toLowerCase() || 'sqlite') as Dialect
  if (!['sqlite', 'pg', 'mysql'].includes(d)) {
    throw new Error(`Unknown DB_DIALECT: ${d}. Must be 'sqlite' | 'pg' | 'mysql'.`)
  }
  return d
}

export const isSqlite = (): boolean => getDialect() === 'sqlite'
export const isPg = (): boolean => getDialect() === 'pg'
export const isMysql = (): boolean => getDialect() === 'mysql'
