Carry source f591fa64e525679a31c9db7f942d36c789e1a12f forward from 72a1e57. Preserve lab4 attachment transactions, reconciliation locks, quarantine, and existing schema data through verified legacy adoption. Keep report and evidence work in progress untouched.
29 lines
841 B
Python
29 lines
841 B
Python
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "0004_attachment_quarantine"
|
|
down_revision = "0003_attachments"
|
|
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")
|