Vote #80110
完了Add redmine_plugin_migration generator
0%
説明
Redmine provides @redmine_plugin_model@ generator. It's similar to @model@ generator by Rails but for Redmine plugin. It's useful to add a new model to Redmine plugin.
But Redmine doesn't provide @redmine_plugin_migration@ generator. It's similar to @migration@ generator by Rails but for Redmine plugin. It's useful to improve existing models in Redmine plugin.
We need to create a migration file for Redmine plugin by hand without @redmine_plugin_migration@.
The attached patch implements @redmine_plugin_migration@ generator. It only has the minimal features:
- Assign a new migration version.
- Just create a migration file that only has empty @change@ method.
The @migration@ generator by Rails has more features:
- Intelligent migration content generator. For example it can generate a migration content for creating a table from @create_TABLE_NAME@ migration name: https://github.com/rails/rails/blob/master/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb#L39-L41
- Migration name validation: https://github.com/rails/rails/blob/master/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb#L65-L69
- Accept more options. For example, attributes are accepted: https://github.com/rails/rails/blob/master/activerecord/lib/rails/generators/active_record/migration/migration_generator.rb#L8
I think that minimum implementation is a good starting point.
This implementation uses the framework for migration provided by Rails: https://github.com/rails/rails/blob/master/railties/lib/rails/generators/migration.rb
journals
--------------------------------------------------------------------------------
>I think that minimum implementation is a good starting point.
+1, nice work!
This is a minute thing but `plugin_pretty_name` declared in line 16 of redmine_plugin_migration_generator.rb is not used so far and probably can be safely removed.
--------------------------------------------------------------------------------
Good catch.
I've updated the patch.
--------------------------------------------------------------------------------
Setting the target version to 4.1.0.
--------------------------------------------------------------------------------
Committed the patch. Thank you.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------