"""Add rag_project_id to conversations; auto_summary columns to projects."""

from alembic import op

revision = "0030"
down_revision = "0029"


def upgrade() -> None:
    op.execute("""
        ALTER TABLE conversations
            ADD COLUMN IF NOT EXISTS rag_project_id INTEGER DEFAULT NULL
    """)
    op.execute("""
        ALTER TABLE projects
            ADD COLUMN IF NOT EXISTS auto_summary TEXT DEFAULT NULL,
            ADD COLUMN IF NOT EXISTS summary_updated_at TIMESTAMPTZ DEFAULT NULL
    """)


def downgrade() -> None:
    op.execute("ALTER TABLE conversations DROP COLUMN IF EXISTS rag_project_id")
    op.execute("ALTER TABLE projects DROP COLUMN IF EXISTS auto_summary, DROP COLUMN IF EXISTS summary_updated_at")
