2016-09-29 18:10:23 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const DBMigrate = require('db-migrate');
|
|
|
|
const path = require('path');
|
2016-11-12 11:21:40 +01:00
|
|
|
const parseDbUrl = require('parse-database-url');
|
2016-09-29 18:10:23 +02:00
|
|
|
|
2016-11-12 11:21:40 +01:00
|
|
|
function migrateDb (dbUrl, schema = "public") {
|
|
|
|
const custom = parseDbUrl(dbUrl);
|
|
|
|
custom.schema = schema;
|
2016-09-29 18:10:23 +02:00
|
|
|
const dbmigrate = DBMigrate.getInstance(true, {
|
2016-11-10 21:15:16 +01:00
|
|
|
cwd: __dirname,
|
2016-11-12 11:21:40 +01:00
|
|
|
config: { custom },
|
2016-09-29 18:10:23 +02:00
|
|
|
env: 'custom' }
|
|
|
|
);
|
|
|
|
return dbmigrate.up();
|
|
|
|
}
|
|
|
|
|
2016-11-10 21:15:16 +01:00
|
|
|
module.exports = migrateDb;
|