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