create table jobs
(
    id          integer
        constraint jobs_pk
            primary key autoincrement,
    task_id     integer                        not null
        constraint jobs_tasks_id_fk
            references tasks,
    status_id   integer                        not null
        constraint jobs_statuses_id_fk
            references statuses,
    output      TEXT,
    started_at  TEXT default CURRENT_TIMESTAMP not null,
    finished_at TEXT,
    "order"     integer                        not null
);

create index jobs_task_id_order_index
    on jobs (task_id asc, "order" desc);

