Class: AddDeviseToDeviseModel

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/old_sql/templates/add_devise_to_users_migration.rb

Class Method Summary collapse

Class Method Details

.downObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/generators/old_sql/templates/add_devise_to_users_migration.rb', line 39

def self.down
  if column_exists? :devise_model, :alternative_admin_email
    remove_column :devise_model, :email, :string
    remove_column :devise_model, :alternative_admin_email, :string
  end
  remove_column :devise_model, :encrypted_password
  remove_column :devise_model, :password_salt
  remove_column :devise_model, :authentication_token
  remove_column :devise_model, :confirmation_token
  remove_column :devise_model, :confirmed_at
  remove_column :devise_model, :confirmation_sent_at
  remove_column :devise_model, :reset_password_token
  remove_column :devise_model, :remember_token
  remove_column :devise_model, :remember_created_at
  remove_column :devise_model, :sign_in_count
  remove_column :devise_model, :current_sign_in_at
  remove_column :devise_model, :last_sign_in_at
  remove_column :devise_model, :current_sign_in_ip
  remove_column :devise_model, :last_sign_in_ip
  remove_column :devise_model, :failed_attempts
  remove_column :devise_model, :unlock_token
  remove_column :devise_model, :locked_at
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/old_sql/templates/add_devise_to_users_migration.rb', line 2

def self.up
  null    = false
  default = ""

  unless column_exists? :devise_model, :email
    add_column :devise_model, :email, :string
    add_column :devise_model, :alternative_admin_email, :string
  end
  add_column :devise_model, :encrypted_password, :string, :null => null, :default => default, :limit => 128
  add_column :devise_model, :password_salt, :string
  add_column :devise_model, :authentication_token, :string
  add_column :devise_model, :confirmation_token,   :string
  add_column :devise_model, :confirmed_at,         :datetime
  add_column :devise_model, :confirmation_sent_at, :datetime
  add_column :devise_model, :reset_password_token, :string
  add_column :devise_model, :remember_token,      :string
  add_column :devise_model, :remember_created_at, :datetime
  add_column :devise_model, :sign_in_count,      :integer, :default => 0
  add_column :devise_model, :current_sign_in_at, :datetime
  add_column :devise_model, :last_sign_in_at,    :datetime
  add_column :devise_model, :current_sign_in_ip, :string
  add_column :devise_model, :last_sign_in_ip,    :string

  #:lockable fields contributed by MattSlay
  add_column :devise_model, :failed_attempts, :integer, :default => 0
  add_column :devise_model, :unlock_token,   :string
  add_column :devise_model, :locked_at, :datetime

  unless column_exists? :devise_model, :updated_at
    add_column :devise_model, :updated_at, :datetime
  end
  
  unless column_exists? :devise_model, :created_at
    add_column :devise_model, :created_at, :datetime
  end
end