This commit is contained in:
runny committed 2026-06-04 13:49:46 +08:00
1 parent 0baa3921bc
commit 6fed283e4c
1 file changed
+52
@@ -0,0 +1,52 @@
"""repair schema drift indexes and constraints
Revision ID: d0e1f2a3b4c5
Revises: c9d8e7f6a5b4
Create Date: 2026-06-03 12:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd0e1f2a3b4c5'
down_revision = 'c9d8e7f6a5b4'
branch_labels = None
depends_on = None
def upgrade():
op.create_index('ix_kb_documents_group_id', 'kb_documents', ['group_id'], unique=False)
op.create_index(
'ix_kb_document_versions_document_id',
'kb_document_versions',
['document_id'],
unique=False,
)
op.create_index('ix_schedule_tasks_last_run_at', 'schedule_tasks', ['last_run_at'], unique=False)
op.create_index('ix_schedule_tasks_created_at', 'schedule_tasks', ['created_at'], unique=False)
op.execute("UPDATE schedule_runs SET wecom_notified = false WHERE wecom_notified IS NULL")
op.alter_column(
'schedule_runs',
'wecom_notified',
existing_type=sa.Boolean(),
nullable=False,
existing_server_default=sa.text('false'),
)
def downgrade():
op.alter_column(
'schedule_runs',
'wecom_notified',
existing_type=sa.Boolean(),
nullable=True,
existing_server_default=sa.text('false'),
)
op.drop_index('ix_schedule_tasks_created_at', table_name='schedule_tasks')
op.drop_index('ix_schedule_tasks_last_run_at', table_name='schedule_tasks')
op.drop_index('ix_kb_document_versions_document_id', table_name='kb_document_versions')
op.drop_index('ix_kb_documents_group_id', table_name='kb_documents')