gitlab-org--gitlab-foss/db/migrate/20140914145549_migrate_to_new_members_model.rb
Dmitriy Zaporozhets 1aa48174db
Fix STI+polymorphic for Group <-> GroupMember
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
2014-09-14 21:52:54 +03:00

11 lines
553 B
Ruby

class MigrateToNewMembersModel < ActiveRecord::Migration
def up
execute "INSERT INTO members ( user_id, source_id, source_type, access_level, notification_level, type ) SELECT user_id, group_id, 'Namespace', group_access, notification_level, 'GroupMember' FROM users_groups"
execute "INSERT INTO members ( user_id, source_id, source_type, access_level, notification_level, type ) SELECT user_id, project_id, 'Project', project_access, notification_level, 'ProjectMember' FROM users_projects"
end
def down
Member.delete_all
end
end