Files
RAGcore-Public/alembic/versions/0014_document_space.py
T

42 lines
1.3 KiB
Python

"""Associate documents with the knowledge space they were ingested into.
No production row exists yet (ingestion was never wired to a worker handler
until this change), so this adds the column as NOT NULL directly rather than
nullable-then-backfill-then-constrain: there is nothing to backfill.
Deliberately no FK to control.spaces: content.documents.workspace_id already
has no FK to control.workspaces (control and content are separate bounded
contexts in this schema, and cross-schema FKs have no other precedent in
this codebase), so space_id follows the same established convention --
indexed, not foreign-key-enforced.
"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
revision = "0014_document_space"
down_revision = "0013_generation_profiles"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column(
"documents",
sa.Column("space_id", sa.Uuid(), nullable=False),
schema="content",
)
op.create_index(
"ix_content_documents_space",
"documents",
["space_id"],
schema="content",
)
def downgrade() -> None:
op.drop_index("ix_content_documents_space", table_name="documents", schema="content")
op.drop_column("documents", "space_id", schema="content")