32 lines
1021 B
JavaScript
32 lines
1021 B
JavaScript
const { Pool } = require('pg');
|
|
const pool = new Pool({host: 'localhost', port: 5432, user: 'postgres', password: 'password123', database: 'ckqr'});
|
|
async function run() {
|
|
try {
|
|
await pool.query(`
|
|
CREATE TABLE IF NOT EXISTS app_settings (
|
|
key VARCHAR(255) PRIMARY KEY,
|
|
value TEXT,
|
|
category VARCHAR(50),
|
|
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
`);
|
|
console.log('Created app_settings table.');
|
|
|
|
await pool.query(`
|
|
INSERT INTO app_settings (key, value, category) VALUES
|
|
('smtp_host', 'smtp.office365.com', 'smtp'),
|
|
('smtp_port', '587', 'smtp'),
|
|
('smtp_user', 'noreply@cavininfotech.com', 'smtp'),
|
|
('smtp_pass', 'xmkshjlszjbkcyzb', 'smtp'),
|
|
('smtp_secure', 'false', 'smtp')
|
|
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value;
|
|
`);
|
|
console.log('Inserted SMTP settings.');
|
|
} catch (err) {
|
|
console.error(err);
|
|
} finally {
|
|
process.exit(0);
|
|
}
|
|
}
|
|
run();
|