gabriel / musehub public
0063_mpack_index_full_coverage.py python
61 lines 1.7 KB
Raw
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7 test(mwp3): Phase 4 — fix adjacent suite regressions, lock … Sonnet 4.6 22 days ago
1 """Extend musehub_pack_index to cover commits and snapshots.
2
3 Renames:
4 object_id → entity_id
5 pack_id → mpack_id
6
7 Adds:
8 entity_type VARCHAR(16) NOT NULL — "object", "commit", or "snapshot"
9 Backfills existing rows with entity_type = 'object'.
10
11 Renames index ix_musehub_pack_index_object_id → ix_musehub_pack_index_entity_id.
12 """
13
14 from __future__ import annotations
15
16 import sqlalchemy as sa
17 from alembic import op
18
19 revision = "0063"
20 down_revision = "0062"
21 branch_labels = None
22 depends_on = None
23
24
25 def upgrade() -> None:
26 op.drop_index("ix_musehub_pack_index_object_id", table_name="musehub_pack_index")
27
28 with op.batch_alter_table("musehub_pack_index") as batch_op:
29 batch_op.alter_column("object_id", new_column_name="entity_id")
30 batch_op.alter_column("pack_id", new_column_name="mpack_id")
31 batch_op.add_column(
32 sa.Column(
33 "entity_type",
34 sa.String(16),
35 nullable=False,
36 server_default="object",
37 )
38 )
39
40 op.execute("UPDATE musehub_pack_index SET entity_type = 'object'")
41
42 op.create_index(
43 "ix_musehub_pack_index_entity_id",
44 "musehub_pack_index",
45 ["entity_id"],
46 )
47
48
49 def downgrade() -> None:
50 op.drop_index("ix_musehub_pack_index_entity_id", table_name="musehub_pack_index")
51
52 with op.batch_alter_table("musehub_pack_index") as batch_op:
53 batch_op.drop_column("entity_type")
54 batch_op.alter_column("mpack_id", new_column_name="pack_id")
55 batch_op.alter_column("entity_id", new_column_name="object_id")
56
57 op.create_index(
58 "ix_musehub_pack_index_object_id",
59 "musehub_pack_index",
60 ["object_id"],
61 )
File History 2 commits
sha256:969ddc5e88776e70af33c016b8777bb721356508ae5f304b3fb46c451494ece7 test(mwp3): Phase 4 — fix adjacent suite regressions, lock … Sonnet 4.6 22 days ago
sha256:1749b9cc5cd2583c56d3261c4c00a342c27435f3946d4bc3e70f76aa2795458a docs(mwp-3): TDD implementation plan for job-enqueue idempo… Opus 4.8 22 days ago