Commit 788d99feb4daeaf55217173d7abe81e97a04b06f
1 parent
c5156e92
Exists in
profile_api_improvements
and in
1 other branch
Fixes migration to use any role in community when creating community followers
Showing
1 changed file
with
4 additions
and
4 deletions
Show diff stats
db/migrate/20160608123748_create_profile_followers_table.rb
... | ... | @@ -19,8 +19,8 @@ class CreateProfileFollowersTable < ActiveRecord::Migration |
19 | 19 | |
20 | 20 | #insert one category for each friend group a person has |
21 | 21 | execute("INSERT INTO circles(name, person_id, profile_type) SELECT DISTINCT (CASE WHEN (f.group IS NULL OR f.group = '') THEN 'friendships' ELSE f.group END), f.person_id, 'Person' FROM friendships as f") |
22 | - #insert 'memberships' category if a person is in a community as a member, moderator or profile admin | |
23 | - execute("INSERT INTO circles(name, person_id, profile_type) SELECT DISTINCT 'memberships', ra.accessor_id, 'Community' FROM role_assignments as ra JOIN roles ON ra.role_id = roles.id WHERE roles.name IN ('Member','Moderator','Profile Administrator')") | |
22 | + #insert 'memberships' category if a person is in a community as any role | |
23 | + execute("INSERT INTO circles(name, person_id, profile_type) SELECT DISTINCT 'memberships', ra.accessor_id, 'Community' FROM role_assignments as ra JOIN profiles ON ra.resource_id = profiles.id WHERE ra.resource_type = 'Profile' AND profiles.type = 'Community'") | |
24 | 24 | #insert 'favorites' category if a person has any favorited enterprise |
25 | 25 | execute("INSERT INTO circles(name, person_id, profile_type) SELECT DISTINCT 'favorites', person_id, 'Enterprise' FROM favorite_enterprise_people") |
26 | 26 | |
... | ... | @@ -28,8 +28,8 @@ class CreateProfileFollowersTable < ActiveRecord::Migration |
28 | 28 | execute("INSERT INTO profiles_circles(profile_id, circle_id) SELECT DISTINCT f.friend_id, c.id FROM friendships as f JOIN circles as c ON f.person_id = c.person_id WHERE c.name = f.group OR c.name = 'friendships'") |
29 | 29 | #insert a follower entry for each favorited enterprise, with the category 'favorites' |
30 | 30 | execute("INSERT INTO profiles_circles(profile_id, circle_id) SELECT DISTINCT f.enterprise_id, c.id FROM favorite_enterprise_people AS f JOIN circles as c ON f.person_id = c.person_id WHERE c.name = 'favorites' ") |
31 | - #insert a follower entry for each community a person participates as a member, moderator or admininstrator | |
32 | - execute("INSERT INTO profiles_circles(profile_id, circle_id) SELECT DISTINCT ra.resource_id, c.id FROM role_assignments as ra JOIN roles ON ra.role_id = roles.id JOIN circles as c ON ra.accessor_id = c.person_id WHERE roles.name IN ('Member','Moderator','Profile Administrator') AND c.name = 'memberships'") | |
31 | + #insert a follower entry for each community a person participates with any role | |
32 | + execute("INSERT INTO profiles_circles(profile_id, circle_id) SELECT DISTINCT ra.resource_id, c.id FROM role_assignments as ra JOIN profiles ON ra.accessor_id = profiles.id JOIN circles as c ON ra.accessor_id = c.person_id WHERE ra.resource_type = 'Profile' AND profiles.type = 'Community' AND c.name = 'memberships'") | |
33 | 33 | end |
34 | 34 | |
35 | 35 | def down | ... | ... |