create table if not exists project_skill
(
    id           bigserial
        primary key,
    project_uuid uuid                                                         not null,
    slug         varchar(255)                                                 not null,
    name         varchar(255)                                                 not null,
    description  text,
    source       varchar(20)              default 'manual'::character varying not null,
    repo_id      uuid,
    content      text                     default ''::text                    not null,
    metadata     jsonb                    default '{}'::jsonb                 not null,
    enabled      boolean                  default true                        not null,
    created_by   uuid,
    created_at   timestamp with time zone default now()                       not null,
    updated_at   timestamp with time zone default now()                       not null,
    commit_sha   varchar(40),
    blob_hash    varchar(40),
    unique (project_uuid, slug)
);

create index if not exists idx_project_skill_project
    on project_skill (project_uuid);

create index if not exists idx_project_skill_slug
    on project_skill (slug);

create index if not exists idx_project_skill_source
    on project_skill (source);

create index if not exists idx_project_skill_commit_sha
    on project_skill (commit_sha);

create index if not exists idx_project_skill_blob_hash
    on project_skill (blob_hash);
