45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
|
|
// Quick DB verification. Run: npx tsx scripts/check-db.ts
|
||
|
|
import "dotenv/config";
|
||
|
|
import { prisma } from "@/lib/db";
|
||
|
|
|
||
|
|
async function main() {
|
||
|
|
const tables = await prisma.$queryRawUnsafe<{ table_name: string }[]>(
|
||
|
|
"select table_name from information_schema.tables where table_schema = 'public' order by table_name"
|
||
|
|
);
|
||
|
|
const names = tables.map((t) => t.table_name);
|
||
|
|
console.log(`Tables (${names.length}):`, names.join(", "));
|
||
|
|
|
||
|
|
const expected = [
|
||
|
|
"user",
|
||
|
|
"session",
|
||
|
|
"account",
|
||
|
|
"verification",
|
||
|
|
"organization",
|
||
|
|
"member",
|
||
|
|
"invitation",
|
||
|
|
"subscription",
|
||
|
|
"episode",
|
||
|
|
"script",
|
||
|
|
"audio_asset",
|
||
|
|
"cover_art",
|
||
|
|
"generation_job",
|
||
|
|
"plan",
|
||
|
|
"usage_record",
|
||
|
|
"api_key",
|
||
|
|
"audit_log",
|
||
|
|
];
|
||
|
|
const have = new Set(names);
|
||
|
|
const missing = expected.filter((t) => !have.has(t));
|
||
|
|
console.log(missing.length ? `MISSING: ${missing.join(", ")}` : "✓ All expected tables present");
|
||
|
|
|
||
|
|
const [users, plans] = await Promise.all([prisma.user.count(), prisma.plan.count()]);
|
||
|
|
console.log(`Users: ${users} · Plans: ${plans}`);
|
||
|
|
}
|
||
|
|
|
||
|
|
main()
|
||
|
|
.catch((e) => {
|
||
|
|
console.error("Check failed:", e.message ?? e);
|
||
|
|
process.exit(1);
|
||
|
|
})
|
||
|
|
.finally(() => prisma.$disconnect());
|