2016-09-29 18:10:23 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-12-13 13:59:52 +01:00
|
|
|
require('db-migrate-shared').log.setLogLevel('error');
|
|
|
|
|
2016-11-13 15:15:33 +01:00
|
|
|
const { getInstance } = require('db-migrate');
|
2016-11-12 11:21:40 +01:00
|
|
|
const parseDbUrl = require('parse-database-url');
|
2016-09-29 18:10:23 +02:00
|
|
|
|
2017-06-28 14:10:32 +02:00
|
|
|
function migrateDb({ databaseUrl, databaseSchema = 'public' }) {
|
2016-12-03 13:45:22 +01:00
|
|
|
const custom = parseDbUrl(databaseUrl);
|
2016-11-13 15:15:33 +01:00
|
|
|
custom.schema = databaseSchema;
|
|
|
|
const dbmigrate = getInstance(true, {
|
2016-11-10 21:15:16 +01:00
|
|
|
cwd: __dirname,
|
2016-11-12 11:21:40 +01:00
|
|
|
config: { custom },
|
2017-06-28 14:10:32 +02:00
|
|
|
env: 'custom',
|
|
|
|
});
|
2016-09-29 18:10:23 +02:00
|
|
|
return dbmigrate.up();
|
|
|
|
}
|
|
|
|
|
2016-11-13 15:15:33 +01:00
|
|
|
module.exports = migrateDb;
|