create table if not exists project
(
    id           uuid                     not null
        primary key,
    name         varchar(255)             not null,
    display_name varchar(255)             not null,
    avatar_url   varchar(255),
    description  text,
    is_public    boolean default false    not null,
    created_by   uuid                     not null,
    created_at   timestamp with time zone not null,
    updated_at   timestamp with time zone not null,
    workspace_id uuid
                                          references workspace
                                              on delete set null
);

create index if not exists idx_project_name
    on project (name);

create index if not exists idx_project_created_by
    on project (created_by);

create index if not exists idx_project_workspace_id
    on project (workspace_id)
    where (workspace_id IS NOT NULL);

create unique index if not exists idx_workspace_slug
    on workspace (slug);

create index if not exists idx_workspace_deleted_at
    on workspace (deleted_at);
