Files
Jellystat/backend/migrations/030_jf_logging_table.js
2024-09-24 23:21:22 -07:00

29 lines
886 B
JavaScript

exports.up = async function(knex) {
try {
const hasTable = await knex.schema.hasTable('jf_logging');
if (!hasTable) {
await knex.schema.createTable('jf_logging', function(table) {
table.text('Id').primary();
table.text('Name').notNullable();
table.text('Type').notNullable();
table.text('ExecutionType');
table.text('Duration').notNullable();
table.timestamp('TimeRun').defaultTo(knex.fn.now());
table.json('Log');
table.text('Result');
});
await knex.raw(`ALTER TABLE jf_logging OWNER TO "${process.env.POSTGRES_ROLE}";`);
}
} catch (error) {
console.error(error);
}
};
exports.down = async function(knex) {
try {
await knex.schema.dropTableIfExists('jf_logging');
} catch (error) {
console.error(error);
}
};