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:
@@ -5,12 +5,12 @@ import path from "path";
|
||||
* Global integration setup.
|
||||
*
|
||||
* Only needed when running against a real Postgres via TEST_DATABASE_URL: reset the
|
||||
* schema and apply every migration once before the workers start. When
|
||||
* TEST_DATABASE_URL is not set, each worker spins up its own in-process PGlite database
|
||||
* (see tests/helpers/integration-setup.ts) and this is a no-op.
|
||||
* schema and apply every Drizzle migration once before the workers start. When
|
||||
* TEST_DATABASE_URL is not set, each worker spins up its own in-process PGlite
|
||||
* database (see tests/helpers/integration-setup.ts) and this is a no-op.
|
||||
*/
|
||||
|
||||
const MIGRATIONS_DIR = path.resolve(process.cwd(), "prisma", "migrations");
|
||||
const MIGRATIONS_DIR = path.resolve(process.cwd(), "lib", "db", "migrations");
|
||||
|
||||
export default async function setup() {
|
||||
const connectionString = process.env.TEST_DATABASE_URL?.trim();
|
||||
@@ -23,11 +23,11 @@ export default async function setup() {
|
||||
await client.connect();
|
||||
try {
|
||||
await client.query("DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public;");
|
||||
const dirs = readdirSync(MIGRATIONS_DIR)
|
||||
.filter((entry) => /^\d/.test(entry))
|
||||
const files = readdirSync(MIGRATIONS_DIR)
|
||||
.filter((entry) => entry.endsWith(".sql"))
|
||||
.sort();
|
||||
for (const dir of dirs) {
|
||||
await client.query(readFileSync(path.join(MIGRATIONS_DIR, dir, "migration.sql"), "utf8"));
|
||||
for (const file of files) {
|
||||
await client.query(readFileSync(path.join(MIGRATIONS_DIR, file), "utf8"));
|
||||
}
|
||||
} finally {
|
||||
await client.end();
|
||||
|
||||
Reference in New Issue
Block a user