Best practices and caveats for After_party tasks
masterIdempotency
Crucial: Tasks may fail halfway through and will not record progress. Because these are often data updates, rollbacks are not supported. Always design your tasks to be idempotent, meaning they can be run multiple times without causing side effects or errors.
Data vs. Schema Migrations
- Schema Migrations: Used for structural changes to the database. Use these if you need to manipulate data during a structural change (e.g., populating a new column) and can handle model-DB mismatches.
- After_party Tasks: Intended for data migrations. Use these for complex logic, external data imports, or cleaning up invalid data using Ruby code and Rails models. They run after migrations are complete, so your models will always match the current schema.