40 lines
1.8 KiB
JavaScript
40 lines
1.8 KiB
JavaScript
// Read-only diagnostic: execute the exact SQL shape the generated Prisma client
|
|
// emits for deck.findMany() / materialGroup.findMany() against a DB built purely
|
|
// from `prisma migrate deploy` (predev + Docker entrypoint flow).
|
|
// Proves DBAUD-01: migrated DB is incompatible with the shipped client.
|
|
const path = require("node:path");
|
|
const Database = require("better-sqlite3");
|
|
|
|
const dbPath = path.resolve("audit-results/tmp/audit-migration.db");
|
|
const db = new Database(dbPath, { readonly: true });
|
|
|
|
// 1. Shape of prisma.deck.findMany({ include: { class: true } }) — Prisma selects
|
|
// every scalar field, including groupId (schema.prisma:33-34, generated client).
|
|
const deckSql =
|
|
'SELECT "Deck"."id", "Deck"."classId", "Deck"."name", "Deck"."description", "Deck"."sortOrder", "Deck"."createdAt", "Deck"."groupId" FROM "Deck"';
|
|
try {
|
|
db.prepare(deckSql).all();
|
|
console.log("deck.findMany SQL: OK");
|
|
} catch (e) {
|
|
console.log("deck.findMany SQL: FAILED ->", e.message);
|
|
}
|
|
|
|
// 2. Shape of prisma.materialGroup.findMany()
|
|
const groupSql = 'SELECT "MaterialGroup"."id", "MaterialGroup"."classId", "MaterialGroup"."name", "MaterialGroup"."type", "MaterialGroup"."sortOrder", "MaterialGroup"."createdAt" FROM "MaterialGroup"';
|
|
try {
|
|
db.prepare(groupSql).all();
|
|
console.log("materialGroup.findMany SQL: OK");
|
|
} catch (e) {
|
|
console.log("materialGroup.findMany SQL: FAILED ->", e.message);
|
|
}
|
|
|
|
// 3. Shape of prisma.shareLink.findFirst() (share page validation)
|
|
const shareSql = 'SELECT "ShareLink"."id", "ShareLink"."targetType", "ShareLink"."deckId", "ShareLink"."quizSetId", "ShareLink"."groupId", "ShareLink"."createdAt" FROM "ShareLink" LIMIT 1';
|
|
try {
|
|
db.prepare(shareSql).all();
|
|
console.log("shareLink.findFirst SQL: OK");
|
|
} catch (e) {
|
|
console.log("shareLink.findFirst SQL: FAILED ->", e.message);
|
|
}
|
|
|
|
db.close();
|