mirror of
https://github.com/internetee/registry.git
synced 2025-07-01 16:53:37 +02:00
Migration edit
This commit is contained in:
parent
ef75de17d4
commit
3d0271669f
1 changed files with 5 additions and 6 deletions
|
@ -1,13 +1,12 @@
|
|||
class RefactorRoles < ActiveRecord::Migration
|
||||
def change
|
||||
def up
|
||||
add_column :users, :roles, :string, array: true
|
||||
|
||||
User.all.each do |x|
|
||||
c = x.role.try(:code)
|
||||
if c
|
||||
x.roles = [c]
|
||||
x.save
|
||||
end
|
||||
r = x.role
|
||||
next unless r
|
||||
x.roles = [r.code]
|
||||
x.save
|
||||
end
|
||||
|
||||
remove_column :users, :role_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue