mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 15:30:56 +00:00
26 lines
641 B
JavaScript
26 lines
641 B
JavaScript
const { Client } = require('pg');
|
|
|
|
(async function createSchema(){
|
|
const client = new Client({
|
|
host: 'localhost',
|
|
port: 5432,
|
|
user: 'postgres',
|
|
password: '',
|
|
database: 'edr_freight',
|
|
});
|
|
|
|
try {
|
|
console.log('Connecting to Postgres...');
|
|
await client.connect();
|
|
console.log('Creating schema freight if not exists...');
|
|
await client.query('CREATE SCHEMA IF NOT EXISTS freight');
|
|
console.log('Schema ensured.');
|
|
await client.end();
|
|
process.exit(0);
|
|
} catch (err) {
|
|
console.error('Failed to create schema:', err);
|
|
try { await client.end(); } catch {}
|
|
process.exit(1);
|
|
}
|
|
})();
|