0021_add_deleted_at_to_musehub_objects.py
python
sha256:a10adeeb7a0169cb9900f9806ed7a973047258abb6283724fe55e8eb68ff3f0a
init: musehub initial commit
Human
171 days ago
| 1 | """Add deleted_at to musehub_objects for soft-delete support. |
| 2 | |
| 3 | Objects are logically deleted by setting deleted_at; hard-delete |
| 4 | runs only after the retention window (object_retention_days config). |
| 5 | |
| 6 | Revision ID: 0021 |
| 7 | Revises: 0020 |
| 8 | """ |
| 9 | from __future__ import annotations |
| 10 | |
| 11 | import sqlalchemy as sa |
| 12 | from alembic import op |
| 13 | |
| 14 | revision = "0021" |
| 15 | down_revision = "0020" |
| 16 | branch_labels = None |
| 17 | depends_on = None |
| 18 | |
| 19 | |
| 20 | def upgrade() -> None: |
| 21 | op.add_column( |
| 22 | "musehub_objects", |
| 23 | sa.Column( |
| 24 | "deleted_at", |
| 25 | sa.DateTime(timezone=True), |
| 26 | nullable=True, |
| 27 | server_default=None, |
| 28 | ), |
| 29 | ) |
| 30 | op.create_index( |
| 31 | "ix_musehub_objects_deleted_at", |
| 32 | "musehub_objects", |
| 33 | ["deleted_at"], |
| 34 | ) |
| 35 | |
| 36 | |
| 37 | def downgrade() -> None: |
| 38 | op.drop_index("ix_musehub_objects_deleted_at", table_name="musehub_objects") |
| 39 | op.drop_column("musehub_objects", "deleted_at") |
File History
1 commit
sha256:a10adeeb7a0169cb9900f9806ed7a973047258abb6283724fe55e8eb68ff3f0a
init: musehub initial commit
Human
171 days ago