ЛР7 - БВТ2302 - Зюлина - на 3
Skeleton contracts / contracts (pull_request) Blocked by required conditions

This commit is contained in:
2026-11-29 12:55:09 +03:00
parent 20afc2c790
commit 5b8c2a22e1
54 changed files with 2781 additions and 94 deletions
+29
View File
@@ -0,0 +1,29 @@
"""Add durable staging and asynchronous attachment job state."""
from alembic import op
import sqlalchemy as sa
revision = "005_async_attachments"
down_revision = "004_attachments"
branch_labels = None
depends_on = None
def upgrade():
op.add_column("attachments", sa.Column("staging_key", sa.String(128), nullable=True))
op.add_column("attachments", sa.Column("job_id", sa.String(36), nullable=True))
op.add_column("attachments", sa.Column("error_code", sa.String(64), nullable=True))
op.add_column("attachments", sa.Column("variants", sa.JSON(), nullable=False, server_default="[]"))
op.execute("UPDATE attachments SET staging_key = object_key, job_id = id")
op.alter_column("attachments", "staging_key", nullable=False)
op.alter_column("attachments", "job_id", nullable=False)
op.create_unique_constraint("uq_attachments_staging_key", "attachments", ["staging_key"])
op.create_unique_constraint("uq_attachments_job_id", "attachments", ["job_id"])
def downgrade():
op.drop_constraint("uq_attachments_job_id", "attachments", type_="unique")
op.drop_constraint("uq_attachments_staging_key", "attachments", type_="unique")
op.drop_column("attachments", "variants")
op.drop_column("attachments", "error_code")
op.drop_column("attachments", "job_id")
op.drop_column("attachments", "staging_key")