Created
February 18, 2013 17:01
-
-
Save rodrigoulisses/4978851 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RemovePersonIdAndAddIndividualIdInToEmployee < ActiveRecord::Migration | |
def change | |
add_column :compras_employees, :individual_id, :integer | |
add_index :compras_employees, :individual_id | |
add_foreign_key :compras_employees, :unico_individuals, | |
:column => :individual_id | |
execute <<-SQL | |
UPDATE compras_employees AS ce | |
SET individual_id = (SELECT personable_id | |
FROM unico_people | |
WHERE id = ce.person_id and personable_type = "Individual") | |
SQL | |
remove_column :compras_employees, :person_id | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment