diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 18:09:23 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 18:09:23 +0300 |
commit | e9b32005ebaa432f0fb40d3c87f9d0bf9b109db9 (patch) | |
tree | 3eb99893112196c74f09712c43230e47567d7364 /db | |
parent | 757426dbb18b5c62670b6090d6fed25fc71528a1 (diff) | |
download | gitlab-ce-e9b32005ebaa432f0fb40d3c87f9d0bf9b109db9.tar.gz |
Migrate old membership objects to new Member model
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20140914145549_migrate_to_newmembers_model.rb | 31 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 32 insertions, 1 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 diff --git a/db/schema.rb b/db/schema.rb index b926ca5de9f..41ae717c670 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140914113604) do +ActiveRecord::Schema.define(version: 20140914145549) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |