CREATE TABLE IF NOT EXISTS repos (
    repo_id UUID PRIMARY KEY,
    repo_hash TEXT NOT NULL,
    repo_path TEXT NOT NULL,
    UNIQUE(repo_hash, repo_path)
);

CREATE TABLE langchain_pg_collection (
    name VARCHAR UNIQUE,
    cmetadata JSON,
    uuid      UUID PRIMARY KEY
);

CREATE TABLE langchain_pg_embedding (
    collection_id UUID REFERENCES langchain_pg_collection ON DELETE CASCADE,
    embedding     VECTOR,
    document      VARCHAR,
    cmetadata     JSON,
    uuid          UUID PRIMARY KEY
);

CREATE INDEX langchain_pg_embedding_collection_id ON langchain_pg_embedding (collection_id);