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
|
class RefactorRoles < ActiveRecord::Migration
|
||||||
def change
|
def up
|
||||||
add_column :users, :roles, :string, array: true
|
add_column :users, :roles, :string, array: true
|
||||||
|
|
||||||
User.all.each do |x|
|
User.all.each do |x|
|
||||||
c = x.role.try(:code)
|
r = x.role
|
||||||
if c
|
next unless r
|
||||||
x.roles = [c]
|
x.roles = [r.code]
|
||||||
x.save
|
x.save
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_column :users, :role_id
|
remove_column :users, :role_id
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue