# This file contains scripts for incremental database versions, sorted from
# newest to oldest. Each version starts with VERSION <number>. All contents
# until the next version is the script for that version. Statements are
# separated by ';'. It is also possible to use classes, which can perform
# more complex migration logic. To do that, the line must start with the
# <class> keyword, followed by the fully qualified name of the migration
# class, which should implement org.cyclos.db.Migration. It still should be
# followed up by a ';' to end the line.
# For function definitions which requires ';' in the middle, it is possible
# to use the DELIMITER keyword to change a delimiter, so, for example,
# DELIMITER EOF will make all lines until the word EOF be a single statement.

VERSION 2
alter table service_logs add column custom_ws_id bigint;

VERSION 1

create table logging_version (
    version integer not null
);

create table service_logs (
    date timestamp default now() not null,
    cyclos_version varchar not null,
    service_name varchar not null,
    method_name varchar not null,
    success boolean not null,
    time_taken integer not null,
    parameters json,
    result json,
    error json,
    error_stack_trace text,
    network_id bigint,
    network_name varchar,
    configuration_id bigint,
    configuration_name varchar,
    channel_id bigint,
    channel_name varchar,
    remote_address varchar,
    principal_type_id bigint,
    principal_type_name varchar,
    principal varchar,
    session_token varchar,
    user_id bigint,
    user_display varchar,
    group_id bigint,
    group_name varchar
);

create table task_logs (
    date timestamp default now() not null,
    cyclos_version varchar not null,
    name varchar not null,
    success boolean not null,
    affected_records integer,
    time_taken integer,
    error_stack_trace text
);

VERSION 0