feat: estrutura banco de dados para Multi-Tenancy com usuario_id e suporta roteiro continuo na IA
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
const { Pool } = require('pg');
|
||||
require('dotenv').config();
|
||||
|
||||
const pool = new Pool({
|
||||
connectionString: process.env.DATABASE_URL
|
||||
});
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const tablesRes = await pool.query(`
|
||||
SELECT table_name
|
||||
FROM information_schema.tables
|
||||
WHERE table_schema = 'escola'
|
||||
ORDER BY table_name;
|
||||
`);
|
||||
|
||||
console.log('--- TABELAS NO ESQUEMA escola ---');
|
||||
for (const row of tablesRes.rows) {
|
||||
console.log(`\nTabela: ${row.table_name}`);
|
||||
const columnsRes = await pool.query(`
|
||||
SELECT column_name, data_type, is_nullable, column_default
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = 'escola' AND table_name = $1
|
||||
ORDER BY ordinal_position;
|
||||
`, [row.table_name]);
|
||||
|
||||
for (const col of columnsRes.rows) {
|
||||
console.log(` - ${col.column_name}: ${col.data_type} (null: ${col.is_nullable}, default: ${col.column_default})`);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Erro ao ler tabelas:', err);
|
||||
} finally {
|
||||
await pool.end();
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user