How to properly initialize Redmine plugins that need to create a model (read the database record) defined in the plugin itself?
For example, I have my_redmine_plugin plugin that comes with the MyPluginModel model. When initializing the plugin, I would like
- read
MyPluginModel entry from DB - run some initialization code with the entry
Given the following code:
require 'redmine' Redmine::Plugin.register :my_redmine_plugin do name 'My Redmine Plugin'
It looks like to_prepare starts before the migration:
$ bundle exec rake redmine:plugins:migrate NAME=my_redmine_plugin `table_structure': Could not find table 'mypluginmodel' (ActiveRecord::StatementInvalid) ...
When I comment on the to_prepare block during the migration, everything works fine. Is there any way to detect the migration process?
source share