/*
 * 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
 */

'use strict';

async function create_app (knex) {
  await knex.schema.createTable ('app', (table) => {
    table.increments ('id');
    table.string ('name');
  });
}

async function create_log (knex) {
  await knex.schema.createTable ('log', (table) => {
    table.increments ('id');
    table.integer ('app_id')
      .references ('id')
      .inTable ('app');
    table.string ('message');
    table.json ('data');
    table.timestamp ('timestamp');
  });
}

async function up (knex) {
  await create_app (knex);
  await create_log (knex);
}

function down () {
  // noop
}

module.exports = { up, down };