gabriel / musehub public

0080_add_musehub_reflog_entries.py file-level

at sha256:8 · View file ↗ · Intel ↗

History
1 files
1 commits
0 hotspots
0 🧊 dead
0 💥 blast risk
sha256:1 fix: getting-started page's muse --version sample output showed musehub… · gabriel · Oct 23, 2026
1 """Add musehub_reflog_entries table
2
3 Stores branch reflog entries shared from a Muse CLI client via the wire
4 protocol (muse#54 item 4). Entries are immutable history, so the natural
5 key is a content hash of every field (entry_id) rather than a mutable
6 (repo_id, branch) pointer — re-pushing the same entry is a true no-op.
7
8 Revision ID: 0080
9 Revises: 0079
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 = '0080'
21 down_revision: Union[str, None] = '0079'
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 op.create_table('musehub_reflog_entries',
28 sa.Column('entry_id', sa.String(length=128), nullable=False),
29 sa.Column('repo_id', sa.String(length=128), nullable=False),
30 sa.Column('branch', sa.String(length=500), nullable=False),
31 sa.Column('old_id', sa.String(length=128), nullable=False),
32 sa.Column('new_id', sa.String(length=128), nullable=False),
33 sa.Column('author', sa.String(length=255), nullable=False),
34 sa.Column('operation', sa.Text(), nullable=False),
35 sa.Column('timestamp', sa.DateTime(timezone=True), nullable=False),
36 sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
37 sa.ForeignKeyConstraint(['repo_id'], ['musehub_repos.repo_id'], ondelete='CASCADE'),
38 sa.PrimaryKeyConstraint('entry_id'),
39 )
40 op.create_index(op.f('ix_musehub_reflog_entries_repo_id'), 'musehub_reflog_entries', ['repo_id'], unique=False)
41 op.create_index('ix_musehub_reflog_entries_repo_branch', 'musehub_reflog_entries', ['repo_id', 'branch'], unique=False)
42
43
44 def downgrade() -> None:
45 op.drop_index('ix_musehub_reflog_entries_repo_branch', table_name='musehub_reflog_entries')
46 op.drop_index(op.f('ix_musehub_reflog_entries_repo_id'), table_name='musehub_reflog_entries')
47 op.drop_table('musehub_reflog_entries')