does not apply legacy_issue migration if plugin installed after legacy_issue incident

pull/6827/head
Jens Ulferts 11 years ago
parent 4c71fff5cd
commit 9d4c7d44ce
  1. 11
      db/migrate/20130916094369_legacy_issues_costs_data_to_work_packages.rb

@ -14,6 +14,8 @@ require Rails.root.join("db","migrate","migration_utils","utils").to_s
class LegacyIssuesCostsDataToWorkPackages < ActiveRecord::Migration
def up
return unless migration_applicable?
execute <<-SQL
UPDATE work_packages
SET cost_object_id = (SELECT legacy_issues.cost_object_id
@ -24,6 +26,8 @@ class LegacyIssuesCostsDataToWorkPackages < ActiveRecord::Migration
end
def down
return unless migration_applicable?
execute <<-SQL
UPDATE legacy_issues
SET cost_object_id = (SELECT work_packages.cost_object_id
@ -32,4 +36,11 @@ class LegacyIssuesCostsDataToWorkPackages < ActiveRecord::Migration
LIMIT 1)
SQL
end
private
def migration_applicable?
ActiveRecord::Base.connection.table_exists?('legacy_issues') &&
ActiveRecord::Base.connection.columns('legacy_issues').map(&:name).include?('cost_object_id')
end
end

Loading…
Cancel
Save