"""add lease_until to jobs Revision ID: Revises: d60dfc3e075a Create Date: """ from __future__ import annotations from alembic import op revision = "6980f998def1" down_revision = "d60dfc3e075a" branch_labels = None depends_on = None def upgrade() -> None: op.execute(""" ALTER TABLE jobs ADD COLUMN IF NOT EXISTS lease_until TIMESTAMPTZ """) op.execute(""" CREATE INDEX IF NOT EXISTS jobs_processing_expired_idx ON jobs (lease_until) WHERE status = 'processing' """) def downgrade() -> None: op.execute("DROP INDEX IF EXISTS jobs_processing_expired_idx") op.execute("ALTER TABLE jobs DROP COLUMN IF EXISTS lease_until")