// See https://vincit.github.io/objection.js/#models // for more of what you can do here. const { Model } = require('objection'); class logs extends Model { static get tableName(){ return 'logs'; } static get idColumn(){ return 'log'; } } module.exports = function (app) { const db = app.get('knex'); db.schema.hasTable('logs').then(exists => { if (!exists) { db.schema.createTable('logs', table => { table.increments('log'); table.uuid('trace') table.string('path'); table.string('method'); table.string('provider'); table.string('id'); table.string('ip'); table.text('messages'); table.jsonb('query') table.jsonb('error'); table.jsonb('data'); table.jsonb('result'); table.timestamp('timeStart'); table.integer('user'); table.string('userEmail'); table.string('userPermissions'); table.string('user-agent'); table.integer('duration'); table.string('machine'); }) .then(() => console.log('Created logs table')) // eslint-disable-line no-console .catch(e => console.error('Error creating logs table', e)); // eslint-disable-line no-console } }) .catch(e => console.error('Error creating logs table', e)); // eslint-disable-line no-console return logs; };