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              text not null primary key,
    label           text,
    domain          text,
    client_id       text,
    client_secret   text,
    wellknown_url   text,
    _version        text
);

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

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

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

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

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

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