This repository has no description
1import pg from "pg";
2import { readFileSync } from "node:fs";
3function loadConn() {
4 if (process.env.DB_CONNECTION_STRING) return process.env.DB_CONNECTION_STRING;
5 for (const p of ["../.env", ".env", "../../.env"]) {
6 try {
7 const m = readFileSync(p, "utf8").match(/^\s*DB_CONNECTION_STRING\s*=\s*(.+)\s*$/m);
8 if (m) return m[1].trim();
9 } catch {}
10 }
11 throw new Error("DB_CONNECTION_STRING not found");
12}
13const pool = new pg.Pool({ connectionString: loadConn(), ssl: { rejectUnauthorized: false }, max: 3 });
14
15console.log("=== all tables/views (every schema) ===");
16console.table((await pool.query(`
17 select table_schema, table_name, table_type
18 from information_schema.tables
19 where table_schema not in ('pg_catalog','information_schema')
20 order by table_schema, table_name`)).rows);
21
22console.log("\n=== columns matching 'embed' or 'readme' (any table) ===");
23const hits = await pool.query(`
24 select table_schema, table_name, column_name, data_type
25 from information_schema.columns
26 where table_schema not in ('pg_catalog','information_schema')
27 and (column_name ~* 'embed|readme|vector')
28 order by table_schema, table_name, ordinal_position`);
29console.table(hits.rows.length ? hits.rows : [{ note: "no columns named embed*/readme*/vector*" }]);
30
31console.log("\n=== tables matching 'embed' or 'readme' by NAME ===");
32const tn = await pool.query(`
33 select table_schema, table_name from information_schema.tables
34 where table_name ~* 'embed|readme'
35 order by 1,2`);
36console.table(tn.rows.length ? tn.rows : [{ note: "no table named embed*/readme*" }]);
37
38// If a readme column/table exists, show count + sample
39for (const r of [...hits.rows, ...tn.rows]) {
40 const t = `"${r.table_schema}"."${r.table_name}"`;
41 try {
42 const c = await pool.query(`select count(*)::int n from ${t}`);
43 console.log(`count ${t}: ${c.rows[0].n}`);
44 } catch (e) { /* ignore dup */ }
45}
46
47console.log("\n=== columns on tangled_repos (did a readme/embedding col get added here?) ===");
48console.table((await pool.query(`
49 select column_name, data_type from information_schema.columns
50 where table_schema='public' and table_name='tangled_repos' order by ordinal_position`)).rows);
51
52await pool.end();