0020_add_updated_at_to_critical_tables.py
python
sha256:a10adeeb7a0169cb9900f9806ed7a973047258abb6283724fe55e8eb68ff3f0a
init: musehub initial commit
Human
171 days ago
| 1 | """Add updated_at to musehub_repos, musehub_proposals, musehub_webhooks, musehub_releases. |
| 2 | |
| 3 | These are the highest-traffic mutable tables that were missing updated_at — |
| 4 | required for audit trails and cache invalidation. |
| 5 | |
| 6 | Revision ID: 0020 |
| 7 | Revises: 0019 |
| 8 | """ |
| 9 | from __future__ import annotations |
| 10 | |
| 11 | import sqlalchemy as sa |
| 12 | from alembic import op |
| 13 | |
| 14 | revision = "0020" |
| 15 | down_revision = "0019" |
| 16 | branch_labels = None |
| 17 | depends_on = None |
| 18 | |
| 19 | _TABLES = [ |
| 20 | "musehub_repos", |
| 21 | "musehub_proposals", |
| 22 | "musehub_webhooks", |
| 23 | "musehub_releases", |
| 24 | ] |
| 25 | |
| 26 | |
| 27 | def upgrade() -> None: |
| 28 | for table in _TABLES: |
| 29 | op.add_column( |
| 30 | table, |
| 31 | sa.Column( |
| 32 | "updated_at", |
| 33 | sa.DateTime(timezone=True), |
| 34 | nullable=False, |
| 35 | server_default=sa.func.now(), |
| 36 | ), |
| 37 | ) |
| 38 | |
| 39 | |
| 40 | def downgrade() -> None: |
| 41 | for table in _TABLES: |
| 42 | op.drop_column(table, "updated_at") |
File History
1 commit
sha256:a10adeeb7a0169cb9900f9806ed7a973047258abb6283724fe55e8eb68ff3f0a
init: musehub initial commit
Human
171 days ago