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 32 |
# File 'lib/redmine_plugins_helper/migration.rb', line 28 def applied? schema_migration = ::ActiveRecord::Base.connection_pool.schema_migration schema_migration.create_table schema_migration.versions.include?(database_version) 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(*migrator_context_args).up do |m| m.version == version end end |
#core? ⇒ Boolean
40 41 42 |
# File 'lib/redmine_plugins_helper/migration.rb', line 40 def core? plugin_id == PLUGIN_ID_CORE_VALUE end |
#database_version ⇒ String
35 36 37 |
# File 'lib/redmine_plugins_helper/migration.rb', line 35 def database_version core? ? version.to_s : "#{version}-#{plugin_id}" end |
#plugin ⇒ Redmine::Plugin
45 46 47 |
# File 'lib/redmine_plugins_helper/migration.rb', line 45 def plugin plugin? ? ::Redmine::Plugin.find(plugin_id) : nil end |
#plugin? ⇒ Boolean
50 51 52 |
# File 'lib/redmine_plugins_helper/migration.rb', line 50 def plugin? !core? end |