@@ -443,7 +443,7 module Redmine #:nodoc: | |||||
443 | class Migrator < ActiveRecord::Migrator |
|
443 | class Migrator < ActiveRecord::Migrator | |
444 | # We need to be able to set the 'current' plugin being migrated. |
|
444 | # We need to be able to set the 'current' plugin being migrated. | |
445 | cattr_accessor :current_plugin |
|
445 | cattr_accessor :current_plugin | |
446 |
|
446 | |||
447 | class << self |
|
447 | class << self | |
448 | # Runs the migrations from a plugin, up (or down) to the version given |
|
448 | # Runs the migrations from a plugin, up (or down) to the version given | |
449 | def migrate_plugin(plugin, version) |
|
449 | def migrate_plugin(plugin, version) | |
@@ -451,7 +451,7 module Redmine #:nodoc: | |||||
451 | return if current_version(plugin) == version |
|
451 | return if current_version(plugin) == version | |
452 | migrate(plugin.migration_directory, version) |
|
452 | migrate(plugin.migration_directory, version) | |
453 | end |
|
453 | end | |
454 |
|
454 | |||
455 | def current_version(plugin=current_plugin) |
|
455 | def current_version(plugin=current_plugin) | |
456 | # Delete migrations that don't match .. to_i will work because the number comes first |
|
456 | # Delete migrations that don't match .. to_i will work because the number comes first | |
457 | ::ActiveRecord::Base.connection.select_values( |
|
457 | ::ActiveRecord::Base.connection.select_values( | |
@@ -459,14 +459,14 module Redmine #:nodoc: | |||||
459 | ).delete_if{ |v| v.match(/-#{plugin.id}/) == nil }.map(&:to_i).max || 0 |
|
459 | ).delete_if{ |v| v.match(/-#{plugin.id}/) == nil }.map(&:to_i).max || 0 | |
460 | end |
|
460 | end | |
461 | end |
|
461 | end | |
462 |
|
462 | |||
463 | def migrated |
|
463 | def migrated | |
464 | sm_table = self.class.schema_migrations_table_name |
|
464 | sm_table = self.class.schema_migrations_table_name | |
465 | ::ActiveRecord::Base.connection.select_values( |
|
465 | ::ActiveRecord::Base.connection.select_values( | |
466 | "SELECT version FROM #{sm_table}" |
|
466 | "SELECT version FROM #{sm_table}" | |
467 | ).delete_if{ |v| v.match(/-#{current_plugin.id}/) == nil }.map(&:to_i).sort |
|
467 | ).delete_if{ |v| v.match(/-#{current_plugin.id}/) == nil }.map(&:to_i).sort | |
468 | end |
|
468 | end | |
469 |
|
469 | |||
470 | def record_version_state_after_migrating(version) |
|
470 | def record_version_state_after_migrating(version) | |
471 | super(version.to_s + "-" + current_plugin.id.to_s) |
|
471 | super(version.to_s + "-" + current_plugin.id.to_s) | |
472 | end |
|
472 | end |
General Comments 0
You need to be logged in to leave comments.
Login now