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)  NOT NULL DEFAULT 'manual',
    repo_id      UUID,
    content      TEXT         NOT NULL DEFAULT '',
    metadata     JSONB        NOT NULL DEFAULT '{}',
    enabled      BOOLEAN      NOT NULL DEFAULT true,
    created_by   UUID,
    created_at   TIMESTAMPTZ  NOT NULL DEFAULT NOW(),
    updated_at   TIMESTAMPTZ  NOT NULL DEFAULT NOW(),
    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);
