create table providers (
    id              text not null primary key,
    name            text,
    key             text,
    url             text,
    _version        text
);

create table models (
    id              text not null primary key,
    provider_id     text,
    name            text,
    modelname       text,
    configuration   text,
    _version        text
);

create table settings (
    chat_model_id   text,
    default_lang    text,
    register_enabled numeric,
    password_enabled numeric,
    _version        text
);

create table oidc (
    id              string not null primary key,
    label           string,
    domain          string,
    client_id       string,
    client_secret   string,
    wellknown_url   string,
    _version        text
);

create table users (
    id              string not null primary key,
    firstname       string not null default '',
    lastname        string not null default '',
    password        string not null default '',
    email           string not null unique,
    picture         string not null default '',
    enabled         numeric default true,
    administrator   numeric default false,
    _version        text not null
);

create table user_addresses (
    id              string not null primary key,
    user_id         string,
    type            string,
    address         string,
    _version        text
);

create table channels (
    id              string not null primary key,
    name            string,
    type            string,
    enabled         numeric,
    configuration   string,
    _version        text
);

create table tools (
    id              string not null primary key,
    name            string,
    type            string,
    enabled         numeric,
    configuration   string,
    _version        text
);

create table tasks (
    id              string not null primary key,
    owner_id        string,
    model_id        string,
    label           string,
    prompt          string,
    cron            string,
    status          string,
    next_datetime   numeric,
    _version        text
);

create table history (
    id              string not null primary key,
    task_id         string,
    start_datetimle numeric,
    end_datetime    numeric,
    prompt          string,
    log             string,
    response        string,
    _version        text
);
