# `PhoenixKit.Migrations.Postgres.V42`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/phoenix_kit/migrations/postgres/v42.ex#L1)

PhoenixKit V42 Migration: Universal Scheduled Jobs System

This migration introduces a centralized scheduled jobs system that can handle
any type of scheduled task (posts, emails, notifications, etc.) using a
polymorphic design with behaviour-based handlers.

## Changes

### Scheduled Jobs Table (phoenix_kit_scheduled_jobs)
- Universal job scheduling with polymorphic resource references
- Handler module storage for dynamic dispatch
- Status tracking (pending, executed, failed, cancelled)
- Retry support with attempt tracking
- Priority-based execution ordering
- Flexible metadata via JSONB args field

## Design

The system uses a behaviour pattern where handler modules implement:
- `job_type/0` - Returns the job type string
- `resource_type/0` - Returns the resource type string
- `execute/2` - Executes the job with resource_id and args

## PostgreSQL Support
- Uses binary_id primary key
- Optimized indexes for status + scheduled_at queries
- Supports prefix for schema isolation

# `down`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/phoenix_kit/migrations/postgres/v42.ex#L167)

Rollback the V42 migration.

# `up`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.71/lib/phoenix_kit/migrations/postgres/v42.ex#L36)

Run the V42 migration to add the scheduled jobs system.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
