37 lines
1.3 KiB
Python
37 lines
1.3 KiB
Python
"""track retryable task-list purge cleanup
|
|
|
|
Revision ID: 0015_purge_operations
|
|
Revises: 0014_preserve_task_due_times
|
|
"""
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision = "0015_purge_operations"
|
|
down_revision = "0014_preserve_task_due_times"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"purge_operations",
|
|
sa.Column("id", sa.Uuid(), nullable=False),
|
|
sa.Column("list_id", sa.Uuid(), nullable=False),
|
|
sa.Column("user_id", sa.Uuid(), nullable=False),
|
|
sa.Column("trash_dir", sa.String(length=1024), nullable=False),
|
|
sa.Column("status", sa.String(length=32), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=False),
|
|
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("list_id"),
|
|
)
|
|
op.create_index("ix_purge_operations_list_id", "purge_operations", ["list_id"])
|
|
op.create_index("ix_purge_operations_user_id", "purge_operations", ["user_id"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_purge_operations_user_id", table_name="purge_operations")
|
|
op.drop_index("ix_purge_operations_list_id", table_name="purge_operations")
|
|
op.drop_table("purge_operations")
|