I actually think initializer is the right place to put those kind of stuff. Or, maybe do you want to put it in bin/setup so you would run it the first time after you clone your application?
Alternatively, there are a few data migration gems that you could use, but I think that’s still not what you are looking for either, right?
It’s an extraction of a basic system I had inside of our monorail. It has been in use in production for us for about 18 months. It’s modeled similar to AR migrations by design. Task classes are subclasses of a base class. The task runner creates a table similar to AR migrations. The task class file names are versioned exactly like AR migrations. Upon running the rake command to run the tasks, it performs the same system as AR migrations. It finds all task files not yet run and executes them one by one. The one major difference is the design of the task running system is each class is independent. If one fails, the task runner continues. AR migrations are designed for linearity.
I wrote a gem which does exactly this: https://github.com/
consultingMD/schlepper.
It's an extraction of a basic system I had inside of our monorail. It has
been in use in production for us for about 18 months. It's modeled similar
to AR migrations by design. Task classes are subclasses of a base class.
The task runner creates a table similar to AR migrations. The task class
file names are versioned exactly like AR migrations. Upon running the rake
command to run the tasks, it performs the same system as AR migrations. It
finds all task files not yet run and executes them one by one. The one
major difference is the design of the task running system is each class is
independent. If one fails, the task runner continues. AR migrations are
designed for linearity.