class XMigra::BranchUpgrade
Constants
- MIGRATION_COMPLETED
- TARGET_BRANCH
Attributes
base_migration[R]
file_path[R]
migration_completed[R]
target_branch[R]
Public Class Methods
new(path)
click to toggle source
# File lib/xmigra/branch_upgrade.rb, line 10 def initialize(path) @file_path = path @warnings = [] verinc_info = {} if path.exist? @found = true begin verinc_info = YAML.load_file(path) rescue Error => e XMigra.log_error(e) warning "Failed to load branch upgrade migration (#{e.class}).\n #{e}" verinc_info = {} end end @base_migration = verinc_info[Migration::FOLLOWS] @target_branch = (XMigra.secure_digest(verinc_info[TARGET_BRANCH]) if verinc_info.has_key? TARGET_BRANCH) @migration_completed = verinc_info[MIGRATION_COMPLETED] @sql = verinc_info['sql'] end
Public Instance Methods
applicable?(mig_chain)
click to toggle source
# File lib/xmigra/branch_upgrade.rb, line 38 def applicable?(mig_chain) return false if mig_chain.length < 1 return false unless (@base_migration && @target_branch) return File.basename(mig_chain[-1].file_path) == XMigra.yaml_path(@base_migration) end
found?()
click to toggle source
# File lib/xmigra/branch_upgrade.rb, line 34 def found? @found end
has_warnings?()
click to toggle source
# File lib/xmigra/branch_upgrade.rb, line 45 def has_warnings? not @warnings.empty? end
migration_completed_id()
click to toggle source
# File lib/xmigra/branch_upgrade.rb, line 63 def migration_completed_id Migration.id_from_filename(XMigra.yaml_path(migration_completed)) end
sql()
click to toggle source
# File lib/xmigra/branch_upgrade.rb, line 53 def sql if Plugin.active @sql.dup.tap do |result| Plugin.active.amend_source_sql(result) end else @sql end end
warnings()
click to toggle source
# File lib/xmigra/branch_upgrade.rb, line 49 def warnings @warnings.dup end
Private Instance Methods
warning(s)
click to toggle source
# File lib/xmigra/branch_upgrade.rb, line 69 def warning(s) s.freeze @warnings << s end