diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 19:09:23 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 19:09:23 +0400 |
commit | e9b32005ebaa432f0fb40d3c87f9d0bf9b109db9 (patch) | |
tree | 3eb99893112196c74f09712c43230e47567d7364 /db/migrate | |
parent | 757426dbb18b5c62670b6090d6fed25fc71528a1 (diff) |
Migrate old membership objects to new Member model
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20140914145549_migrate_to_newmembers_model.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/db/migrate/20140914145549_migrate_to_newmembers_model.rb b/db/migrate/20140914145549_migrate_to_newmembers_model.rb new file mode 100644 index 00000000000..9c4517f95e5 --- /dev/null +++ b/db/migrate/20140914145549_migrate_to_newmembers_model.rb @@ -0,0 +1,31 @@ +class MigrateToNewmembersModel < ActiveRecord::Migration + def up + UsersGroup.find_each(batch_size: 500) do |user_group| + GroupMember.create( + user_id: user_group.user_id, + source_type: 'Group', + source_id: user_group.group_id, + access_level: user_group.group_access, + notification_level: user_group.notification_level, + ) + + print '.' + end + + UsersProject.find_each(batch_size: 500) do |user_project| + ProjectMember.create( + user_id: user_project.user_id, + source_type: 'Project', + source_id: user_project.project_id, + access_level: user_project.project_access, + notification_level: user_project.notification_level, + ) + + print '.' + end + end + + def down + Member.destroy_all + end +end |