feat(db): idempotent migrations + auto-deploy on startup

- Rewrite 0000_init with IF NOT EXISTS on all tables, indexes and enums;
  wrap FK constraints in DO/EXCEPTION blocks so re-runs never fail
- Add missing suggestions table to init migration
- Add migration 0002 to create message_logs table (IF NOT EXISTS)
- Add entrypoint.sh: runs prisma migrate deploy before starting the server
- Update Dockerfile to copy entrypoint.sh and use it as CMD
- Add prisma:migrate script to package.json for manual runs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-02 13:10:33 -05:00
co-authored by Claude Sonnet 4.6
parent 749a1e860d
commit 1e63ed1873
6 changed files with 148 additions and 141 deletions
+1
View File
@@ -11,6 +11,7 @@
"start:prod": "node dist/main",
"prisma:generate": "prisma generate",
"prisma:pull": "prisma db pull",
"prisma:migrate": "prisma migrate deploy",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix"
},
"keywords": [],