-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmigrate_apps.js
More file actions
27 lines (24 loc) · 1.08 KB
/
migrate_apps.js
File metadata and controls
27 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
(async function() {
require('total5');
const db_config = require('./config').database;
require('querybuilderpg').init('default', db_config);
try {
console.log('Running migration...');
await DATA.query(`
ALTER TABLE tbl_applications ADD COLUMN IF NOT EXISTS description TEXT;
ALTER TABLE tbl_applications ADD COLUMN IF NOT EXISTS example TEXT;
ALTER TABLE tbl_applications ADD COLUMN IF NOT EXISTS min INTEGER DEFAULT 0;
ALTER TABLE tbl_applications ADD COLUMN IF NOT EXISTS max INTEGER DEFAULT 0;
ALTER TABLE tbl_applications ADD COLUMN IF NOT EXISTS metadata JSONB DEFAULT '{}'::jsonb;
`).promise();
console.log('Migration successful.');
console.log('Seeding applications...');
const sql = await Total.readfile(PATH.root('plugins/applications/seed.sql'), 'utf8');
await DATA.query(sql).promise();
console.log('Seeding successful.');
process.exit(0);
} catch (e) {
console.error('Error:', e);
process.exit(1);
}
})();