import sqlalchemy as sa from alembic import op revision = "0006_attachment_quarantine" down_revision = "0005_failed_registry" branch_labels = None depends_on = None def upgrade() -> None: op.add_column("attachments", sa.Column("quarantine_reason", sa.Text(), nullable=True)) op.create_check_constraint( "attachments_quarantine_reason_check", "attachments", "quarantine_reason IN ('missing', 'size_mismatch', 'sha_mismatch')", ) op.add_column( "attachments", sa.Column("quarantined_at", sa.DateTime(timezone=True), nullable=True) ) op.create_check_constraint( "attachments_quarantine_check", "attachments", "(quarantine_reason IS NULL) = (quarantined_at IS NULL)", ) def downgrade() -> None: raise RuntimeError("Downgrade would delete quarantine data")