ci: Coolify autodeploy from main; migrate-on-boot and split dev/prod compose
- Add Nitro plugin to apply Drizzle migrations on server boot (skips when DATABASE_URL is unset, e.g. during build). - Split compose: docker-compose.dev.yml (hot-reload + Postgres) vs docker-compose.yml (production/self-host, env-driven, Coolify-deployable). - Add .dockerignore; parameterise compose env; document the autodeploy decision (Coolify watches main, no CI workflow needed) in ADR 0003 and plan.md T12.
This commit is contained in:
13
server/plugins/migrate.ts
Normal file
13
server/plugins/migrate.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { migrate } from 'drizzle-orm/node-postgres/migrator'
|
||||
import { getDb } from '../db/client'
|
||||
|
||||
// Apply pending migrations once when the server boots (dev and prod). Skipped
|
||||
// when DATABASE_URL is unset (e.g. during build) so it never blocks the bundle.
|
||||
export default defineNitroPlugin(async () => {
|
||||
if (!process.env.DATABASE_URL) {
|
||||
console.warn('[migrate] DATABASE_URL not set — skipping migrations')
|
||||
return
|
||||
}
|
||||
await migrate(getDb(), { migrationsFolder: 'server/db/migrations' })
|
||||
console.log('[migrate] migrations applied')
|
||||
})
|
||||
Reference in New Issue
Block a user