"""Book vector search

Revision ID: 6c616cc9d1f0
Revises: c5dfc16bdc66
Create Date: 2026-01-27 22:37:48.077761

"""

from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
import sqlmodel, pgvector


# revision identifiers, used by Alembic.
revision: str = "6c616cc9d1f0"
down_revision: Union[str, None] = "c5dfc16bdc66"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.execute("CREATE EXTENSION IF NOT EXISTS vector")
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "book",
        sa.Column(
            "embedding", pgvector.sqlalchemy.vector.VECTOR(dim=1024), nullable=True
        ),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("book", "embedding")
    # ### end Alembic commands ###
