AppReports/migrations/00000-init.js

39 lines
850 B
JavaScript
Raw Permalink Normal View History

2020-08-19 12:33:09 +02:00
/*
* Copyright (C) Sapphirecode - All Rights Reserved
* This file is part of appreports which is released under GPL-3.0-or-later.
* See file 'LICENSE' for full license details.
* Created by Timo Hocker <timo@scode.ovh>, August 2020
*/
2020-07-29 20:56:03 +02:00
'use strict';
2020-08-16 11:48:06 +02:00
async function create_app (knex) {
await knex.schema.createTable ('app', (table) => {
table.increments ('id');
table.string ('name');
});
}
async function create_log (knex) {
2020-07-29 20:56:03 +02:00
await knex.schema.createTable ('log', (table) => {
table.increments ('id');
2020-08-16 11:48:06 +02:00
table.integer ('app_id')
.references ('id')
.inTable ('app');
2020-07-29 20:56:03 +02:00
table.string ('message');
table.json ('data');
table.timestamp ('timestamp');
});
}
2020-08-16 11:48:06 +02:00
async function up (knex) {
await create_app (knex);
await create_log (knex);
}
2020-07-29 20:56:03 +02:00
function down () {
// noop
}
module.exports = { up, down };