internetee-registry/db/migrate/20150202140346_refactor_roles.rb
2021-04-26 18:54:26 +05:00

18 lines
376 B
Ruby

class RefactorRoles < ActiveRecord::Migration[6.0]
def up
add_column :users, :roles, :string, array: true
User.paper_trail_off!
User.all.each do |x|
x.roles = ['admin']
x.save(validation: false)
end
User.paper_trail_on!
remove_column :users, :role_id
drop_table :roles
drop_table :rights
drop_table :rights_roles
end
end