Created
February 1, 2012 23:31
-
-
Save marka2g/1720148 to your computer and use it in GitHub Desktop.
BK Group Redistribution
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
#Reassign All Markets and children to a new region | |
def self.reasign_all_markets_to_new_region(old_region_id, new_region_id) | |
# old_southeast = Group.find_by_id(10870) | |
# new_southeast = Group.find_last_by_name('Southeast') | |
# sql.execute("UPDATE links SET parent_id = #{new_southeast.id} WHERE parent_id=#{old_southeast.id}"); | |
#or | |
# g = Group.find_by_id(7283) | |
# ng = Group.find(12791) | |
# BurgerKing::GroupRedistribution.reasign_all_markets_to_new_region(g.id, ng.id) | |
# from meeting | |
# new_group = Group.new(:store_front_id => 2, :group_name_type_id => 8, :name => "Our New Child") | |
# new_group.save | |
# us.add_child(new) | |
# UPDATE links SET parent_id = 12761 WHERE parent_id = 10860 | |
sql = ActiveRecord::Base.connection(); | |
sql.execute("UPDATE links SET parent_id = #{new_region_id} WHERE parent_id=#{old_region_id}"); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment