2019-10-01 04:18:33 +05:00
|
|
|
const config = require('./knexfile');
|
|
|
|
|
|
2019-11-05 18:01:42 +05:00
|
|
|
const knex = require('knex')(config); // eslint-disable-line import/order
|
|
|
|
|
|
|
|
|
|
(async () => {
|
2019-10-01 04:18:33 +05:00
|
|
|
try {
|
2020-04-30 05:27:46 +05:00
|
|
|
const isExists = await knex.schema.hasTable(config.migrations.tableName);
|
2019-10-01 04:18:33 +05:00
|
|
|
|
2022-04-20 00:52:42 +01:00
|
|
|
await knex.migrate.latest();
|
2020-04-30 05:27:46 +05:00
|
|
|
if (!isExists) {
|
2019-10-01 04:18:33 +05:00
|
|
|
await knex.seed.run();
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
process.exitCode = 1;
|
|
|
|
|
|
|
|
|
|
throw error;
|
|
|
|
|
} finally {
|
|
|
|
|
knex.destroy();
|
|
|
|
|
}
|
|
|
|
|
})();
|