Files
optima/api/tmp-check-opp-schema.ts
T

18 lines
615 B
TypeScript

import { Client } from "pg";
const url = process.env.DATABASE_URL ?? "postgresql://optima:123web123@localhost:5432/optima";
const c = new Client(url);
await c.connect();
const r = await c.query(
"SELECT column_name, is_nullable, column_default FROM information_schema.columns WHERE table_name = 'Opportunity' ORDER BY ordinal_position"
);
console.log("Opportunity columns:");
for (const row of r.rows) {
const nullable = row.is_nullable === "YES" ? "nullable" : "NOT NULL";
console.log(` ${row.column_name}: ${nullable}${row.column_default ? ` (default: ${row.column_default})` : ""}`);
}
await c.end();