Initial commit
This commit is contained in:
34
server/check_columns.js
Normal file
34
server/check_columns.js
Normal file
@@ -0,0 +1,34 @@
|
||||
require('dotenv').config();
|
||||
const { Client } = require('pg');
|
||||
|
||||
const client = new Client({
|
||||
host: process.env.DB_HOST,
|
||||
user: process.env.DB_USER,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_NAME,
|
||||
port: process.env.DB_PORT,
|
||||
});
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
await client.connect();
|
||||
|
||||
const tables = ['job', 'client'];
|
||||
|
||||
for (const table of tables) {
|
||||
console.log(`\n--- Columns in table '${table}' ---`);
|
||||
const res = await client.query(`
|
||||
SELECT column_name, data_type
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = '${table}'
|
||||
ORDER BY ordinal_position;
|
||||
`);
|
||||
res.rows.forEach(r => console.log(`${r.column_name} (${r.data_type})`));
|
||||
}
|
||||
|
||||
await client.end();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user