Commit e9b32005 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Migrate old membership objects to new Member model

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 757426db
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
......@@ -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"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment