0081_add_musehub_symlog_entries.py
python
sha256:4fba330283cca0a6bdd067f2c0ad014062fcfda7e98b19ce8cd1e20290252b08
feat: muse#53 item 4 server side — musehub_symlog_entries
Sonnet 5
minor
⚠ breaking
20 hours ago
| 1 | """Add musehub_symlog_entries table |
| 2 | |
| 3 | Stores symbol-journal entries shared from a Muse CLI client via the wire |
| 4 | protocol (muse#53 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, symbol_addr) pointer — re-pushing the same entry is a true |
| 7 | no-op. Unlike musehub_reflog_entries (per-branch), this table is |
| 8 | per-symbol. |
| 9 | |
| 10 | Revision ID: 0081 |
| 11 | Revises: 0080 |
| 12 | """ |
| 13 | from __future__ import annotations |
| 14 | |
| 15 | from typing import Sequence, Union |
| 16 | |
| 17 | from alembic import op |
| 18 | import sqlalchemy as sa |
| 19 | |
| 20 | |
| 21 | # revision identifiers, used by Alembic. |
| 22 | revision: str = '0081' |
| 23 | down_revision: Union[str, None] = '0080' |
| 24 | branch_labels: Union[str, Sequence[str], None] = None |
| 25 | depends_on: Union[str, Sequence[str], None] = None |
| 26 | |
| 27 | |
| 28 | def upgrade() -> None: |
| 29 | op.create_table('musehub_symlog_entries', |
| 30 | sa.Column('entry_id', sa.String(length=128), nullable=False), |
| 31 | sa.Column('repo_id', sa.String(length=128), nullable=False), |
| 32 | sa.Column('symbol_addr', sa.String(length=1000), nullable=False), |
| 33 | sa.Column('old_content_id', sa.String(length=128), nullable=False), |
| 34 | sa.Column('new_content_id', sa.String(length=128), nullable=False), |
| 35 | sa.Column('commit_id', sa.String(length=128), nullable=False), |
| 36 | sa.Column('author', sa.String(length=255), nullable=False), |
| 37 | sa.Column('operation', sa.Text(), nullable=False), |
| 38 | sa.Column('timestamp', sa.DateTime(timezone=True), nullable=False), |
| 39 | sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), |
| 40 | sa.ForeignKeyConstraint(['repo_id'], ['musehub_repos.repo_id'], ondelete='CASCADE'), |
| 41 | sa.PrimaryKeyConstraint('entry_id'), |
| 42 | ) |
| 43 | op.create_index(op.f('ix_musehub_symlog_entries_repo_id'), 'musehub_symlog_entries', ['repo_id'], unique=False) |
| 44 | op.create_index('ix_musehub_symlog_entries_repo_symbol', 'musehub_symlog_entries', ['repo_id', 'symbol_addr'], unique=False) |
| 45 | |
| 46 | |
| 47 | def downgrade() -> None: |
| 48 | op.drop_index('ix_musehub_symlog_entries_repo_symbol', table_name='musehub_symlog_entries') |
| 49 | op.drop_index(op.f('ix_musehub_symlog_entries_repo_id'), table_name='musehub_symlog_entries') |
| 50 | op.drop_table('musehub_symlog_entries') |
File History
1 commit
sha256:4fba330283cca0a6bdd067f2c0ad014062fcfda7e98b19ce8cd1e20290252b08
feat: muse#53 item 4 server side — musehub_symlog_entries
Sonnet 5
minor
⚠
20 hours ago