0080_add_musehub_reflog_entries.py
python
sha256:80674069cfe8fe062c526a103e1cd0f855009d1cd06662ca3ae8393e1545a400
feat: muse#54 item 4 server side — musehub_reflog_entries
Sonnet 5
minor
⚠ breaking
12 hours ago
| 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') |
File History
1 commit
sha256:80674069cfe8fe062c526a103e1cd0f855009d1cd06662ca3ae8393e1545a400
feat: muse#54 item 4 server side — musehub_reflog_entries
Sonnet 5
minor
⚠
12 hours ago