Determine if Maintenance Tasks is the right tool for your use case
mainMaintenance Tasks is designed specifically for ephemeral, collection-based data migrations (e.g., backfilling values for a new NOT NULL column).
Use Maintenance Tasks if:
- You need to perform a one-off data migration.
- Your task is collection-based (e.g., iterates over a database table or a CSV file).
- You need the ability to pause, interrupt, or throttle the task to control database load.
- You want a web UI to manage the task status (start, pause, restart).
Do NOT use Maintenance Tasks if:
- Regular tasks: If the task needs to run on a schedule, use Active Job with a scheduler/cron or
job-iterationinstead. - Schema changes: If you are changing the database schema itself, use a standard Rails migration.
- Non-interruptible tasks: If your application cannot handle a half-completed migration, this tool is not suitable as tasks are designed to be pausable/cancellable.
- Non-collection tasks: If the task doesn't iterate over a set of records, you won't benefit from throttling or interruption features.
- Simple background jobs: If the task doesn't need to be interruptible or managed via a UI, a standard Active Job is preferred.