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:
@@ -10,7 +10,8 @@ import {
|
||||
getPortfolioMediaBindings,
|
||||
replaceEntityMediaUsages,
|
||||
} from "@/lib/media";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { db } from "@/lib/db";
|
||||
import { mediaUsage } from "@/lib/db/schema";
|
||||
import { createMediaAsset as seedAsset } from "@/tests/helpers/factories";
|
||||
|
||||
describe("createMediaAsset / getMediaAssetById", () => {
|
||||
@@ -110,13 +111,11 @@ describe("getPortfolioMediaBindings", () => {
|
||||
const section = await seedAsset();
|
||||
const asset = await seedAsset();
|
||||
|
||||
await prisma.mediaUsage.createMany({
|
||||
data: [
|
||||
await db.insert(mediaUsage).values([
|
||||
{ assetId: cover.id, usageType: "PORTFOLIO_COVER", entityType: "portfolio-project", entityId: "proj", fieldKey: "cover" },
|
||||
{ assetId: section.id, usageType: "PORTFOLIO_SECTION", entityType: "portfolio-project", entityId: "proj", fieldKey: "sec_1" },
|
||||
{ assetId: asset.id, usageType: "PORTFOLIO_ASSET", entityType: "portfolio-project", entityId: "proj", fieldKey: "ast_1" },
|
||||
],
|
||||
});
|
||||
]);
|
||||
|
||||
const bindings = await getPortfolioMediaBindings("proj");
|
||||
expect(bindings.coverAssetId).toBe(cover.id);
|
||||
@@ -131,7 +130,5 @@ describe("getPortfolioMediaBindings", () => {
|
||||
});
|
||||
|
||||
async function createMediaUsageFor(assetId: string) {
|
||||
await prisma.mediaUsage.create({
|
||||
data: { assetId, usageType: "GENERIC", entityType: "e", entityId: "1", fieldKey: "f" },
|
||||
});
|
||||
await db.insert(mediaUsage).values({ assetId, usageType: "GENERIC", entityType: "e", entityId: "1", fieldKey: "f" });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user