Class: RedminePluginsHelper::Migration
- Inherits:
-
Object
- Object
- RedminePluginsHelper::Migration
- Defined in:
- lib/redmine_plugins_helper/migration.rb,
lib/redmine_plugins_helper/migration/code.rb,
lib/redmine_plugins_helper/migration/database.rb
Defined Under Namespace
Constant Summary collapse
- PLUGIN_ID_CORE_VALUE =
:_core_
Instance Method Summary collapse
- #applied? ⇒ Boolean
- #apply ⇒ void
- #core? ⇒ Boolean
- #database_version ⇒ String
- #plugin ⇒ Redmine::Plugin
- #plugin? ⇒ Boolean
Instance Method Details
#applied? ⇒ Boolean
28 29 30 31 |
# File 'lib/redmine_plugins_helper/migration.rb', line 28 def applied? ::ActiveRecord::SchemaMigration.create_table ::ActiveRecord::SchemaMigration.where(version: database_version).any? end |
#apply ⇒ void
This method returns an undefined value.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/redmine_plugins_helper/migration.rb', line 16 def apply return if applied? nyi unless plugin? ::Redmine::Plugin::Migrator.current_plugin = plugin ::Redmine::Plugin::MigrationContext.new(plugin.migration_directory).up do |m| m.version == version end end |
#core? ⇒ Boolean
39 40 41 |
# File 'lib/redmine_plugins_helper/migration.rb', line 39 def core? plugin_id == PLUGIN_ID_CORE_VALUE end |
#database_version ⇒ String
34 35 36 |
# File 'lib/redmine_plugins_helper/migration.rb', line 34 def database_version core? ? version.to_s : "#{version}-#{plugin_id}" end |
#plugin ⇒ Redmine::Plugin
44 45 46 |
# File 'lib/redmine_plugins_helper/migration.rb', line 44 def plugin plugin? ? ::Redmine::Plugin.find(plugin_id) : nil end |
#plugin? ⇒ Boolean
49 50 51 |
# File 'lib/redmine_plugins_helper/migration.rb', line 49 def plugin? !core? end |