1 class AddStatusToUser < ActiveRecord::Migration[4.2]
2 class User < ApplicationRecord
6 create_enumeration :user_status_enum, %w[pending active confirmed suspended deleted]
8 add_column :users, :status, :user_status_enum, :null => false, :default => "pending"
10 User.where(:visible => false).update_all(:status => "deleted")
11 User.where(:visible => true, :active => 0).update_all(:status => "pending")
12 User.where(:visible => true, :active => 1).update_all(:status => "active")
14 remove_column :users, :active
15 remove_column :users, :visible
19 add_column :users, :visible, :boolean, :default => true, :null => false
20 add_column :users, :active, :integer, :default => 0, :null => false
22 User.where(:status => "active").update_all(:visible => true, :active => 1)
23 User.where(:status => "pending").update_all(:visible => true, :active => 0)
24 User.where(:status => "deleted").update_all(:visible => false, :active => 1)
26 remove_column :users, :status
28 drop_enumeration :user_status_enum