Files
GearBox/tests/helpers/db.ts
Jean-Luc Makiola 3bf1fd7cb8 feat(14-01): add PGlite test helper and generate initial PostgreSQL migration
- Rewrite tests/helpers/db.ts to use drizzle-orm/pglite with async createTestDb()
- Generate initial migration with 13 CREATE TABLE statements in drizzle-pg/
- Add drizzle-pg to biome ignore list (generated files)
- PGlite smoke test confirms migrations apply and seed works
2026-04-04 12:18:50 +02:00

18 lines
498 B
TypeScript

import { drizzle } from "drizzle-orm/pglite";
import { migrate } from "drizzle-orm/pglite/migrator";
import * as schema from "../../src/db/schema.ts";
export async function createTestDb() {
const db = drizzle({ schema });
// Apply migrations from the new PostgreSQL migration directory
await migrate(db, { migrationsFolder: "./drizzle-pg" });
// Seed default Uncategorized category
await db
.insert(schema.categories)
.values({ name: "Uncategorized", icon: "package" });
return db;
}