лаба на 3
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
revision = "e5a12026a001"
|
||||
down_revision = "d9e53b20f7c1"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
op.drop_constraint(
|
||||
"ck_attachments_status",
|
||||
"attachments",
|
||||
type_="check",
|
||||
)
|
||||
op.create_check_constraint(
|
||||
"ck_attachments_status",
|
||||
"attachments",
|
||||
"status IN ('queued', 'processing', 'ready', 'failed')",
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
"attachment_jobs",
|
||||
sa.Column("id", sa.Uuid(), primary_key=True),
|
||||
sa.Column(
|
||||
"attachment_id",
|
||||
sa.Uuid(),
|
||||
sa.ForeignKey("attachments.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
unique=True,
|
||||
),
|
||||
sa.Column(
|
||||
"attempt",
|
||||
sa.Integer(),
|
||||
nullable=False,
|
||||
server_default="1",
|
||||
),
|
||||
sa.Column(
|
||||
"status",
|
||||
sa.String(20),
|
||||
nullable=False,
|
||||
server_default="queued",
|
||||
),
|
||||
sa.Column("published_at", sa.DateTime(timezone=True)),
|
||||
sa.Column("started_at", sa.DateTime(timezone=True)),
|
||||
sa.Column(
|
||||
"created_at",
|
||||
sa.DateTime(timezone=True),
|
||||
nullable=False,
|
||||
server_default=sa.text("CURRENT_TIMESTAMP"),
|
||||
),
|
||||
)
|
||||
|
||||
op.create_index(
|
||||
"ix_attachment_jobs_unpublished",
|
||||
"attachment_jobs",
|
||||
["published_at"],
|
||||
)
|
||||
|
||||
|
||||
def downgrade():
|
||||
op.drop_index(
|
||||
"ix_attachment_jobs_unpublished",
|
||||
table_name="attachment_jobs",
|
||||
)
|
||||
op.drop_table("attachment_jobs")
|
||||
|
||||
op.drop_constraint(
|
||||
"ck_attachments_status",
|
||||
"attachments",
|
||||
type_="check",
|
||||
)
|
||||
op.create_check_constraint(
|
||||
"ck_attachments_status",
|
||||
"attachments",
|
||||
"status IN ('pending', 'ready')",
|
||||
)
|
||||
Reference in New Issue
Block a user