--- worktime

create table worktimes (
    id number(19) primary key,
    project_id number(19) not null references projects(id),
    title varchar2(255 char) not null,

    user_id number(19) not null references users(id),
    days varchar2(4000 char) not null,
    start_hour number(10) not null,
    end_hour number(10) not null,
    "comment" varchar2(4000 char) not null,

    enabled number(1) not null,
    deleted number(1) not null,

    created_at timestamp with time zone not null,
    updated_at timestamp with time zone not null
);

create sequence worktimes_id_seq;

create unique index worktimes_project_uniq
on worktimes(
    case when enabled = 1 
    then project_id end
);
