1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00
planka/server/db/init.js
2022-06-20 18:27:39 +02:00

22 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();
}
})();