new changes
This commit is contained in:
45
scratch/check_user_schema.js
Normal file
45
scratch/check_user_schema.js
Normal file
@@ -0,0 +1,45 @@
|
||||
const { Client } = require('pg');
|
||||
|
||||
const client = new Client({
|
||||
host: '66.116.207.225',
|
||||
port: 5433,
|
||||
database: 'nearledb',
|
||||
user: 'admin',
|
||||
password: 'Package@123#',
|
||||
ssl: false,
|
||||
});
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
await client.connect();
|
||||
console.log('Connected to PostgreSQL successfully!');
|
||||
|
||||
// Get information about columns in app_users
|
||||
const colsRes = await client.query(`
|
||||
SELECT column_name, data_type, is_nullable, column_default
|
||||
FROM information_schema.columns
|
||||
WHERE table_name = 'app_users'
|
||||
ORDER BY ordinal_position;
|
||||
`);
|
||||
|
||||
console.log('\n--- COLUMN SCHEMA FOR app_users ---');
|
||||
console.table(colsRes.rows);
|
||||
|
||||
// Also get indices / constraints
|
||||
const constraintsRes = await client.query(`
|
||||
SELECT conname, pg_get_constraintdef(c.oid)
|
||||
FROM pg_constraint c
|
||||
JOIN pg_namespace n ON n.oid = c.connamespace
|
||||
WHERE conrelid = 'app_users'::regclass;
|
||||
`);
|
||||
console.log('\n--- CONSTRAINTS FOR app_users ---');
|
||||
console.table(constraintsRes.rows);
|
||||
|
||||
} catch (err) {
|
||||
console.error('Error:', err);
|
||||
} finally {
|
||||
await client.end();
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user