update
This commit is contained in:
28
backend/core/migrations/versions/0007_ai_embed_1024.py
Normal file
28
backend/core/migrations/versions/0007_ai_embed_1024.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""ai_core: change embedding dim from 768 to 1024 (bge-m3)
|
||||
|
||||
Revision ID: 0007_embed1024
|
||||
Revises: 0006_ai_core
|
||||
Create Date: 2026-04-17
|
||||
|
||||
"""
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "0007_embed1024"
|
||||
down_revision: str | None = "0006_ai_core"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Drop and recreate with new dimension — truncating old embeddings is fine,
|
||||
# reindex will rebuild them.
|
||||
op.execute("DELETE FROM ai_documents")
|
||||
op.execute("ALTER TABLE ai_documents ALTER COLUMN embedding TYPE vector(1024)")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.execute("DELETE FROM ai_documents")
|
||||
op.execute("ALTER TABLE ai_documents ALTER COLUMN embedding TYPE vector(768)")
|
||||
Reference in New Issue
Block a user