3 class AddStatusToUser < ActiveRecord::Migration[4.2]
5 create_enumeration :user_status_enum, %w[pending active confirmed suspended deleted]
7 add_column :users, :status, :user_status_enum, :null => false, :default => "pending"
9 User.where(:visible => false).update_all(:status => "deleted")
10 User.where(:visible => true, :active => 0).update_all(:status => "pending")
11 User.where(:visible => true, :active => 1).update_all(:status => "active")
13 remove_column :users, :active
14 remove_column :users, :visible
18 add_column :users, :visible, :boolean, :default => true, :null => false
19 add_column :users, :active, :integer, :default => 0, :null => false
21 User.where(:status => "active").update_all(:visible => true, :active => 1)
22 User.where(:status => "pending").update_all(:visible => true, :active => 0)
23 User.where(:status => "deleted").update_all(:visible => false, :active => 1)
25 remove_column :users, :status
27 drop_enumeration :user_status_enum