You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
411 B
JavaScript
23 lines
411 B
JavaScript
const initKnex = require('knex');
|
|
|
|
const knexfile = require('./knexfile');
|
|
|
|
const knex = initKnex(knexfile);
|
|
|
|
(async () => {
|
|
try {
|
|
const isExists = await knex.schema.hasTable(knexfile.migrations.tableName);
|
|
|
|
await knex.migrate.latest();
|
|
if (!isExists) {
|
|
await knex.seed.run();
|
|
}
|
|
} catch (error) {
|
|
process.exitCode = 1;
|
|
|
|
throw error;
|
|
} finally {
|
|
knex.destroy();
|
|
}
|
|
})();
|