Makes schema changes deploy automatically: edit schema -> db:generate -> commit -> push -> Dokploy redeploys -> migrations apply on container start. No more Dokploy database terminal. Components: - src/db/migrate.ts: standalone migrator (single short-lived connection, fails loud on error so a bad migration crashes the container instead of letting the app serve a half-migrated schema) - scripts/build-migrator.mjs: esbuild bundles migrate.ts -> dist/migrate.mjs with drizzle-orm + postgres inlined. Needed because Next.js standalone output keeps neither as a separate node_modules package. - Dockerfile: builder runs db:build-migrator; runner copies migrate.mjs + drizzle/; CMD is 'node migrate.mjs && node server.js' - package.json: db:generate / db:migrate / db:studio / db:pull / db:build-migrator scripts; esbuild promoted to an explicit devDependency - pnpm-lock.yaml resynced BUG FIX: .dockerignore had 'drizzle/' — migration SQL was excluded from the build context, so even a correct Dockerfile COPY would have found nothing. This was the second half (with the .gitignore bug in commit 1) of why the migration pipeline never worked. Now only _archived/_introspected are excluded. Verified: full docker build succeeds; runner image contains migrate.mjs + drizzle baseline; migrator tested end-to-end against a scratch DB (35 tables created, __drizzle_migrations populated, idempotent on rerun).
43 lines
No EOL
648 B
Text
43 lines
No EOL
648 B
Text
# dependencies
|
|
/node_modules
|
|
/.pnp
|
|
.pnp.*
|
|
|
|
# next.js
|
|
/.next/
|
|
/out/
|
|
|
|
# migrator build output (generated by scripts/build-migrator.mjs)
|
|
/dist/
|
|
|
|
# production
|
|
/build
|
|
|
|
# misc
|
|
.DS_Store
|
|
*.pem
|
|
|
|
# debug
|
|
npm-debug.log*
|
|
yarn-debug.log*
|
|
yarn-error.log*
|
|
|
|
# env files
|
|
.env*
|
|
|
|
# vercel
|
|
.vercel
|
|
|
|
# typescript
|
|
*.tsbuildinfo
|
|
|
|
# docker
|
|
.docker/
|
|
data/
|
|
|
|
# NOTE: drizzle/ is intentionally NOT ignored.
|
|
# It holds migration SQL + meta snapshots — these are SOURCE CODE and
|
|
# MUST be committed so the deploy pipeline can apply them on the server.
|
|
# Only transient introspection scratch output is ignored:
|
|
drizzle/_introspected/
|
|
drizzle/_archived_pre_baseline_2026-05-19/ |