31 lines
974 B
JavaScript
31 lines
974 B
JavaScript
const { Pool } = require('pg');
|
|
|
|
const pool = new Pool({
|
|
user: 'enwelo_admin',
|
|
host: '87.106.21.21',
|
|
database: 'enwelo',
|
|
password: 'WX1t1cgP1qK09',
|
|
port: 5432,
|
|
ssl: false
|
|
});
|
|
|
|
async function run() {
|
|
try {
|
|
await pool.query('ALTER TABLE geodaten."potentialflächen_wind" ADD COLUMN IF NOT EXISTS projekt_id VARCHAR(255);');
|
|
console.log('Column projekt_id added successfully.');
|
|
// Set for samern-ohne as default since they want to see it!
|
|
// But wait, what if there's only one row?
|
|
const res = await pool.query('SELECT id FROM geodaten."potentialflächen_wind"');
|
|
console.log('Found rows:', res.rowCount);
|
|
if (res.rowCount === 1) {
|
|
await pool.query("UPDATE geodaten.\"potentialflächen_wind\" SET projekt_id = 'projekt_bw_samern-ohne'");
|
|
console.log('Updated the single row to projekt_bw_samern-ohne');
|
|
}
|
|
} catch(e) {
|
|
console.error('Fehler:', e);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
run();
|