Created
June 6, 2011 07:19
-
-
Save innovationfactory/1009866 to your computer and use it in GitHub Desktop.
VF migration
This file contains hidden or 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
# == Fixing users with broken avatars == | |
# | |
# VF output 'rake avatars:copy_all': | |
# | |
# Ready, but 33 users failed (632, 1796, 2766, 3160, 3269, 4550, 6208, 6247, 6841, 7045, 7803, 7830, 7841, 7842, 7845, 7864 | |
# 7866, 7869, 7872, 7886, 7887, 7910, 7916, 7946, 7962, 7973, 7977, 8148, 8329, 8437, 8497, 8635, 8662). | |
# To fix, run this, and re-run rake avatars:copy_all | |
User.find(632, 1796, 2766, 3160, 3269, 4550, 6208, 6247, 6841, 7045, 7803, 7830, 7841, 7842, 7845, 7864, 7866, 7869, 7872, 7886, 7887, 7910, 7916, 7946, 7962, 7973, 7977, 8148, 8329, 8437, 8497, 8635, 8662).each do |u| | |
u.avatar_file_name = u.avatar_file_name.gsub(/\.[a-z0-9]+$/i, '.jpg') | |
u.save false | |
end | |
# --------------------------- | |
# Private challenges and their members: | |
# Challenge members 25: | |
# [4524, 4524, 4690, 4692, 4720, 4774, 4775, 4777, 4778, 4797, 4802, 4810, 4829, 4890, 5130] | |
# | |
# Challenge members 33: | |
# [4524, 4867, 5003, 5021, 5048] | |
# | |
# Challenge 40: | |
# [7, 16, 17, 409, 1323, 6915, 6944] | |
# --------------------------- | |
# == Migrating portal attachments == | |
# In portal to increment picture IDs: | |
Picture.update_all("id = id + 100") | |
nwp = NewsItem.find :all, :conditions => ["content LIKE ?", '%/pictures/%'] | |
nwp.each do |n| | |
n.content = n.content.gsub(/\/pictures\/([0-9]+)/) { |m| "/pictures/#{$1.to_i + 100}" } | |
n.save false | |
end | |
Also for Section#introduction & Section#body and Portal#description | |
renaming folders: | |
folders = Dir.entries("/data/suite/apps/portal/shared/public/data/pictures") - ['.','..'] | |
folders.each do |f| | |
%x{cd /data/suite/apps/portal/shared/public/data/pictures && mv #{f} #{f.to_i + 100} } | |
end | |
# Copy all picture folders to innovationhub public/data BEFORE migrating portals to groups, | |
# and BEFORE running 'rake assets:convert:all' | |
# | |
# (Later strip off /portal from refs to pictures...) | |
# Portal ID to group ID mappings: | |
# 5 => 181 | |
# 3 => 65 | |
# 2 => 64 | |
# 4 => 177 | |
# Cleanup activities of which the associated label is deleted: | |
a = Activity.with_verbs('idea_label').select{ |x| x.subitem.nil? } | |
a.each(&:destroy) | |
# Aadd memberships to all existing users to All Vodafone group | |
vf = Organization.first | |
g = Group.find_by_slug("all-vodafone") | |
(vf.user_ids - g.member_ids).each do |u| | |
GroupMembership.connection.execute "insert into group_memberships(group_id, user_id, created_at, updated_at, `primary`) values (#{g.id}, #{u}, now(), now(), 0)" | |
end | |
g.update_attribute :member_count, g.members.count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment