Skip to content

Commit

Permalink
[PP-1158] Remove deferredtasks table
Browse files Browse the repository at this point in the history
Remove deferredtask  module and related tests.
Add migration to remove the table in the database.
  • Loading branch information
dbernstein committed Apr 17, 2024
1 parent 0b09ca4 commit 5cc028c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 265 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
"""Remove deferredtasks table
Revision ID: f532186a3d48
Revises: b2353c25a95e
Create Date: 2024-04-17 19:03:20.953330+00:00
"""
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

from alembic import op

# revision identifiers, used by Alembic.
revision = "f532186a3d48"
down_revision = "b2353c25a95e"
branch_labels = None
depends_on = None


def upgrade() -> None:
op.drop_index(op.f("ix_deferredtasks_created"), table_name="deferredtasks")
op.drop_index(op.f("ix_deferredtasks_task_type"), table_name="deferredtasks")
op.drop_index(op.f("ix_deferredtasks_status"), table_name="deferredtasks")
op.drop_table("deferredtasks")
sa.Enum(name="deferredtasktype").drop(op.get_bind(), checkfirst=False)
sa.Enum(name="deferredtaskstatus").drop(op.get_bind(), checkfirst=False)


def downgrade() -> None:
op.create_table(
"deferredtasks",
sa.Column("id", postgresql.UUID(as_uuid=True), nullable=False),
sa.Column("created", sa.DateTime(timezone=True), nullable=False),
sa.Column(
"status",
sa.Enum(
"READY",
"PROCESSING",
"SUCCESS",
"FAILURE",
name="deferredtaskstatus",
),
nullable=False,
),
sa.Column(
"task_type",
sa.Enum(
"INVENTORY_REPORT",
name="deferredtasktype",
),
nullable=False,
),
sa.Column("processing_start_time", sa.DateTime(timezone=True), nullable=True),
sa.Column("processing_end_time", sa.DateTime(timezone=True), nullable=True),
sa.Column("status_details", sa.Unicode(), nullable=True),
sa.Column("data", postgresql.JSONB(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_deferredtasks_created"),
"deferredtasks",
["created"],
unique=False,
)

op.create_index(
op.f("ix_deferredtasks_task_type"),
"deferredtasks",
["task_type"],
unique=False,
)

op.create_index(
op.f("ix_deferredtasks_status"),
"deferredtasks",
["status"],
unique=False,
)
1 change: 0 additions & 1 deletion core/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,6 @@ def _bulk_operation(self):
from core.model.credential import Credential
from core.model.customlist import CustomList, CustomListEntry
from core.model.datasource import DataSource
from core.model.deferredtask import DeferredTask
from core.model.devicetokens import DeviceToken
from core.model.discovery_service_registration import DiscoveryServiceRegistration
from core.model.edition import Edition
Expand Down
135 changes: 0 additions & 135 deletions core/model/deferredtask.py

This file was deleted.

129 changes: 0 additions & 129 deletions tests/core/models/test_deferredtask.py

This file was deleted.

0 comments on commit 5cc028c

Please sign in to comment.