REFACTORED - migrate the data layer from Prisma to Drizzle (unify the stack)

- Add lib/db (Drizzle schema: 7 tables + 6 enums + relations, postgres.js client),
  drizzle.config.ts, lib/db/enums.ts (Prisma-compatible enum objects)
- Rewrite all 14 app consumers + 4 admin components to Drizzle
- Move the test DB layer to Drizzle + in-process PGlite; convert all 8 integration
  test files + factories (371 tests green)
- Remove Prisma: deps, prisma/ schema+migrations, lib/prisma.ts, Dockerfile prisma
  generate; wire db:generate/migrate/push/studio to drizzle-kit; update Makefile
- Preserve the old seed as scripts/legacy-prisma-seed.cjs (needs a Drizzle rewrite)
This commit is contained in:
MOH
2026-08-07 14:18:41 +02:00
parent e377877e7e
commit 0a5f77d8de
48 changed files with 3765 additions and 1358 deletions
+8 -16
View File
@@ -1,4 +1,4 @@
.PHONY: start stop restart deploy logs build ps port health clean-orphans app-shell db-shell db-init db-migrate db-seed prisma-generate prisma-migrate test test-watch help
.PHONY: start stop restart deploy logs build ps port health clean-orphans app-shell db-shell db-init db-migrate db-generate test test-watch help
MIGRATION_NAME ?= init
@@ -38,13 +38,10 @@ db-shell:
docker compose exec db psql -U postgres -d moh_sass
db-init:
docker compose exec app sh -lc "npx prisma generate && npx prisma migrate deploy && npx prisma db seed"
docker compose exec app npm run db:migrate
db-migrate:
docker compose exec app npx prisma migrate deploy
db-seed:
docker compose exec app npx prisma db seed
docker compose exec app npm run db:migrate
test:
@node scripts/test-summary.mjs
@@ -52,11 +49,8 @@ test:
test-watch:
npm run test:watch
prisma-generate:
docker compose exec app npx prisma generate
prisma-migrate:
docker compose exec app npx prisma migrate dev --name $(MIGRATION_NAME)
db-generate:
docker compose exec app npm run db:generate
health:
curl -sS https://mohfarawati.de/api/health
@@ -74,11 +68,9 @@ help:
@echo " make clean-orphans Remove orphaned old containers"
@echo " make app-shell Open shell in app container"
@echo " make db-shell Open PostgreSQL shell"
@echo " make db-init Generate client, apply migrations, run seed"
@echo " make db-migrate Apply prisma migrations"
@echo " make db-seed Seed database data"
@echo " make prisma-generate Run prisma generate"
@echo " make prisma-migrate Create/apply dev migration"
@echo " make db-init Apply Drizzle migrations to the DB"
@echo " make db-migrate Apply Drizzle migrations (drizzle-kit migrate)"
@echo " make db-generate Generate a migration from schema changes (drizzle-kit generate)"
@echo " make health Check app health endpoint via public domain"
@echo " make test Run the whole test suite + print a copy-paste summary"
@echo " make test-watch Run the test suite in watch mode"