mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 20:10:56 +00:00
28 lines
649 B
TypeScript
28 lines
649 B
TypeScript
import { Client } from '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);
|
|
}
|
|
}
|
|
|
|
createSchema();
|