main
 1class DeviseCreateAdminUsers < ActiveRecord::Migration
 2  def migrate(direction)
 3    super
 4    # Create a default user
 5    AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up
 6  end
 7
 8  def change
 9    create_table(:admin_users) do |t|
10      ## Database authenticatable
11      t.string :email,              :null => false, :default => ""
12      t.string :encrypted_password, :null => false, :default => ""
13
14      ## Recoverable
15      t.string   :reset_password_token
16      t.datetime :reset_password_sent_at
17
18      ## Rememberable
19      t.datetime :remember_created_at
20
21      ## Trackable
22      t.integer  :sign_in_count, :default => 0
23      t.datetime :current_sign_in_at
24      t.datetime :last_sign_in_at
25      t.string   :current_sign_in_ip
26      t.string   :last_sign_in_ip
27
28      ## Confirmable
29      # t.string   :confirmation_token
30      # t.datetime :confirmed_at
31      # t.datetime :confirmation_sent_at
32      # t.string   :unconfirmed_email # Only if using reconfirmable
33
34      ## Lockable
35      # t.integer  :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
36      # t.string   :unlock_token # Only if unlock strategy is :email or :both
37      # t.datetime :locked_at
38
39      ## Token authenticatable
40      # t.string :authentication_token
41
42
43      t.timestamps
44    end
45
46    add_index :admin_users, :email,                :unique => true
47    add_index :admin_users, :reset_password_token, :unique => true
48    # add_index :admin_users, :confirmation_token,   :unique => true
49    # add_index :admin_users, :unlock_token,         :unique => true
50    # add_index :admin_users, :authentication_token, :unique => true
51  end
52end