One of the issues we've ran into over at efelle in the development of FusionCMS is having to run maintenance or "upkeep" tasks. We've been utilizing migrations for these items - but doing so feels like a misuse of what migrations are originally intended for.

While migrations are used to scaffold our database layer, our upkeep tasks simply need to perform a single task. These tasks should also be capable of being ran at anytime during the application's lifespan.

With this in mind, we've come up with what we think is a solid and sound approach to performing upkeep tasks for our applications.

  • Upkeep tasks are not tracked when ran like migrations are. There will be no "upkeep" table for example.
  • Unlike migrations, there will only be a single handle method. Upkeep tasks are not meant to be reversed in any manner.
  • Upkeep tasks should be completely independent of one-another. Once registered, it shouldn't matter which order they are ran in.
  • By convention it makes sense to store upkeep tasks within a Support/Upkeep directory - but in reality these tasks can be stored and maintained anywhere in your application.
  • Upkeep tasks will be registered to a global container during runtime. This will simply store the reference to our upkeep tasks in the event that upkeep should be performed.

Theoretically, all of this is possible and can be simply handled through Laravel's Job class interface, but personally, I'd like to streamline the process a bit more - so keep an eye out for a new package dropping under the Caffeinated namespace!