actaeon/db-migrate.cjs

17 lines
431 B
JavaScript
Raw Normal View History

2024-03-30 10:29:55 +00:00
const DBMigrate = require('db-migrate');
const url = new URL(process.env.DATABASE_URL);
url.searchParams.set('multipleStatements', 'true');
process.env.DATABASE_URL = url;
const dbmigrate = DBMigrate.getInstance(true);
if (process.argv[2] === 'up')
dbmigrate.up();
2024-04-16 23:53:34 +00:00
else if (process.argv[2] === 'down')
2024-03-30 10:29:55 +00:00
dbmigrate.down();
2024-04-16 23:53:34 +00:00
else if (process.argv[2] === 'reset')
dbmigrate.reset();
2024-03-30 10:29:55 +00:00
else
console.error('Unknown action', argv[2]);