postgres-js failed to parse DATABASE_URL when the password contained URL-special characters (@ : / # ...). New createSqlClient(): uses DATABASE_URL if set, else falls back to PG* env vars (PGHOST/PGUSER/PGPASSWORD/...) which postgres-js reads directly — password passed verbatim, no URL encoding. docker-compose.prod.yml now sets PG* for the server instead of an inline DSN. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
16 lines
539 B
TypeScript
16 lines
539 B
TypeScript
// Applique les migrations générées (drizzle/*.sql) à la base.
|
|
// bun run db:migrate
|
|
import { drizzle } from "drizzle-orm/postgres-js"
|
|
import { migrate } from "drizzle-orm/postgres-js/migrator"
|
|
import { createSqlClient } from "./client"
|
|
|
|
const client = createSqlClient({ max: 1 })
|
|
if (!client) {
|
|
console.error("Aucune config DB (DATABASE_URL ou PG*) — rien à migrer.")
|
|
process.exit(1)
|
|
}
|
|
const db = drizzle(client)
|
|
|
|
await migrate(db, { migrationsFolder: "./drizzle" })
|
|
console.log("Migrations appliquées.")
|
|
await client.end()
|