gabriel / musehub public
0072_fix_schema_drift.py python
47 lines 2.1 KB
Raw
sha256:a59da49c4611b970fc4b6ae48678ce4943261c213a07ddbd73ce9201df869b4a fix: remove false-positive proposal_comments index drop fro… Sonnet 4.6 patch 4 days ago
1 """Fix ORM↔migration drift: unique constraint, drop unused index, fix merge_strategy default
2
3 Migration 0071 created ix_fetch_mpack_cache_repo_tip as a unique index but
4 the ORM model uses UniqueConstraint. Also drops the unused
5 ix_proposal_comments_author_user_id index and updates the merge_strategy
6 server default from state_overlay to overlay (matching migration 0070's data rename).
7
8 Revision ID: 0072
9 Revises: 0071
10 """
11 from __future__ import annotations
12
13 from typing import Sequence, Union
14
15 from alembic import op
16 import sqlalchemy as sa
17
18
19 # revision identifiers, used by Alembic.
20 revision: str = '0072'
21 down_revision: Union[str, None] = '0071'
22 branch_labels: Union[str, Sequence[str], None] = None
23 depends_on: Union[str, Sequence[str], None] = None
24
25
26 def upgrade() -> None:
27 # ### commands auto generated by Alembic - please adjust! ###
28 op.drop_index(op.f('ix_fetch_mpack_cache_repo_tip'), table_name='musehub_fetch_mpack_cache')
29 op.create_unique_constraint('uq_fetch_mpack_cache_repo_tip', 'musehub_fetch_mpack_cache', ['repo_id', 'tip_commit_id'])
30 op.drop_index(op.f('ix_proposal_comments_author_user_id'), table_name='musehub_proposal_comments')
31 op.alter_column('musehub_proposals', 'merge_strategy',
32 existing_type=sa.VARCHAR(length=50),
33 server_default='overlay',
34 existing_nullable=False)
35 # ### end Alembic commands ###
36
37
38 def downgrade() -> None:
39 # ### commands auto generated by Alembic - please adjust! ###
40 op.alter_column('musehub_proposals', 'merge_strategy',
41 existing_type=sa.VARCHAR(length=50),
42 server_default=sa.text("'state_overlay'::character varying"),
43 existing_nullable=False)
44 op.create_index(op.f('ix_proposal_comments_author_user_id'), 'musehub_proposal_comments', ['author_user_id'], unique=False)
45 op.drop_constraint('uq_fetch_mpack_cache_repo_tip', 'musehub_fetch_mpack_cache', type_='unique')
46 op.create_index(op.f('ix_fetch_mpack_cache_repo_tip'), 'musehub_fetch_mpack_cache', ['repo_id', 'tip_commit_id'], unique=True)
47 # ### end Alembic commands ###
File History 2 commits
sha256:a59da49c4611b970fc4b6ae48678ce4943261c213a07ddbd73ce9201df869b4a fix: remove false-positive proposal_comments index drop fro… Sonnet 4.6 patch 4 days ago
sha256:fee5d0924a77eaf653f8bfb728abc0c5fea1e73ca7c4bd69d99ceb20bee36b1a fix: rename migration from autogenerate hash ID to sequenti… Sonnet 4.6 minor 4 days ago