mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-11 17:26:32 +02:00
31 lines
937 B
TypeScript
31 lines
937 B
TypeScript
|
|
import { db } from "./src/db";
|
|
import { ventesProduits } from "./src/db/schema";
|
|
import { sql } from "drizzle-orm";
|
|
|
|
async function diagnose() {
|
|
console.log("Checking DB connection...");
|
|
try {
|
|
const result = await db.execute(sql`SELECT 1`);
|
|
console.log("DB Connection OK.");
|
|
|
|
console.log("Checking table 'ventes_produits'...");
|
|
const tableCheck = await db.execute(sql`SELECT EXISTS (
|
|
SELECT FROM information_schema.tables
|
|
WHERE table_name = 'ventes_produits'
|
|
)`);
|
|
console.log("Table exists:", tableCheck.rows[0].exists);
|
|
|
|
if (tableCheck.rows[0].exists) {
|
|
const count = await db.select({ count: sql`count(*)` }).from(ventesProduits);
|
|
console.log("Total rows in 'ventes_produits':", count[0].count);
|
|
}
|
|
} catch (err) {
|
|
console.error("Diagnosis failed:", err);
|
|
} finally {
|
|
process.exit(0);
|
|
}
|
|
}
|
|
|
|
diagnose();
|