|
| 1 | +"""add background_tasks_task_execution |
| 2 | +
|
| 3 | +Revision ID: 6df7645cc4d2 |
| 4 | +Revises: b7e1af4c9d02 |
| 5 | +Create Date: 2026-04-19 07:44:06.824688 |
| 6 | +""" |
| 7 | + |
| 8 | +from collections.abc import Sequence |
| 9 | + |
| 10 | +import sqlalchemy as sa |
| 11 | +from alembic import op |
| 12 | + |
| 13 | +# revision identifiers, used by Alembic. |
| 14 | +revision: str = "6df7645cc4d2" |
| 15 | +down_revision: str | None = "b7e1af4c9d02" |
| 16 | +branch_labels: str | Sequence[str] | None = None |
| 17 | +depends_on: str | Sequence[str] | None = None |
| 18 | + |
| 19 | + |
| 20 | +def upgrade() -> None: |
| 21 | + # ### commands auto generated by Alembic - please adjust! ### |
| 22 | + op.create_table( |
| 23 | + "background_tasks_task_execution", |
| 24 | + sa.Column( |
| 25 | + "created_at", |
| 26 | + sa.DateTime(timezone=True), |
| 27 | + server_default=sa.text("(CURRENT_TIMESTAMP)"), |
| 28 | + nullable=False, |
| 29 | + ), |
| 30 | + sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True), |
| 31 | + sa.Column("created_by", sa.String(length=255), nullable=True), |
| 32 | + sa.Column("updated_by", sa.String(length=255), nullable=True), |
| 33 | + sa.Column("id", sa.Uuid(), nullable=False), |
| 34 | + sa.Column("celery_task_id", sa.String(length=64), nullable=True), |
| 35 | + sa.Column("task_name", sa.String(length=255), nullable=False), |
| 36 | + sa.Column("status", sa.String(length=20), nullable=False), |
| 37 | + sa.Column("queue", sa.String(length=64), nullable=False), |
| 38 | + sa.Column("args", sa.JSON(), nullable=True), |
| 39 | + sa.Column("kwargs", sa.JSON(), nullable=True), |
| 40 | + sa.Column("result", sa.JSON(), nullable=True), |
| 41 | + sa.Column("traceback", sa.String(), nullable=True), |
| 42 | + sa.Column("exception_type", sa.String(length=255), nullable=True), |
| 43 | + sa.Column("worker", sa.String(length=255), nullable=True), |
| 44 | + sa.Column("retries", sa.Integer(), nullable=False), |
| 45 | + sa.Column("retried_from_id", sa.Uuid(), nullable=True), |
| 46 | + sa.Column("queued_at", sa.DateTime(), nullable=True), |
| 47 | + sa.Column("started_at", sa.DateTime(), nullable=True), |
| 48 | + sa.Column("finished_at", sa.DateTime(), nullable=True), |
| 49 | + sa.Column("heartbeat_at", sa.DateTime(), nullable=True), |
| 50 | + sa.ForeignKeyConstraint( |
| 51 | + ["retried_from_id"], |
| 52 | + ["background_tasks_task_execution.id"], |
| 53 | + name=op.f( |
| 54 | + "fk_background_tasks_task_execution_retried_from_id_background_tasks_task_execution" |
| 55 | + ), |
| 56 | + ), |
| 57 | + sa.PrimaryKeyConstraint("id", name=op.f("pk_background_tasks_task_execution")), |
| 58 | + ) |
| 59 | + op.create_index( |
| 60 | + op.f("ix_background_tasks_task_execution_celery_task_id"), |
| 61 | + "background_tasks_task_execution", |
| 62 | + ["celery_task_id"], |
| 63 | + unique=False, |
| 64 | + ) |
| 65 | + op.create_index( |
| 66 | + op.f("ix_background_tasks_task_execution_retried_from_id"), |
| 67 | + "background_tasks_task_execution", |
| 68 | + ["retried_from_id"], |
| 69 | + unique=False, |
| 70 | + ) |
| 71 | + op.create_index( |
| 72 | + op.f("ix_background_tasks_task_execution_status"), |
| 73 | + "background_tasks_task_execution", |
| 74 | + ["status"], |
| 75 | + unique=False, |
| 76 | + ) |
| 77 | + op.create_index( |
| 78 | + "ix_background_tasks_task_execution_status_queued", |
| 79 | + "background_tasks_task_execution", |
| 80 | + ["status", "queued_at"], |
| 81 | + unique=False, |
| 82 | + ) |
| 83 | + op.create_index( |
| 84 | + op.f("ix_background_tasks_task_execution_task_name"), |
| 85 | + "background_tasks_task_execution", |
| 86 | + ["task_name"], |
| 87 | + unique=False, |
| 88 | + ) |
| 89 | + # ### end Alembic commands ### |
| 90 | + |
| 91 | + |
| 92 | +def downgrade() -> None: |
| 93 | + # ### commands auto generated by Alembic - please adjust! ### |
| 94 | + op.drop_index( |
| 95 | + op.f("ix_background_tasks_task_execution_task_name"), |
| 96 | + table_name="background_tasks_task_execution", |
| 97 | + ) |
| 98 | + op.drop_index( |
| 99 | + "ix_background_tasks_task_execution_status_queued", |
| 100 | + table_name="background_tasks_task_execution", |
| 101 | + ) |
| 102 | + op.drop_index( |
| 103 | + op.f("ix_background_tasks_task_execution_status"), |
| 104 | + table_name="background_tasks_task_execution", |
| 105 | + ) |
| 106 | + op.drop_index( |
| 107 | + op.f("ix_background_tasks_task_execution_retried_from_id"), |
| 108 | + table_name="background_tasks_task_execution", |
| 109 | + ) |
| 110 | + op.drop_index( |
| 111 | + op.f("ix_background_tasks_task_execution_celery_task_id"), |
| 112 | + table_name="background_tasks_task_execution", |
| 113 | + ) |
| 114 | + op.drop_table("background_tasks_task_execution") |
| 115 | + # ### end Alembic commands ### |
0 commit comments