Under the "Getting started" section on https://github.com/plataformatec/devise there is an example migration where a user table is created. However I have already created and executed a migration creating the users table. So the migration I'm looking for adds the desired columns to my existing table.
Is there a smarter way then looking at another database (or the actual source code) and see what columns which needs to be added?
On Wed, Feb 9, 2011 at 2:10 AM, Carlos Antonio da Silva
class AddDeviseColumnsToUser < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.confirmable
t.recoverable
t.rememberable
t.trackable
end
end
def self.down
#the columns below are manually extracted from
https://github.com/plataformatec/devise/blob/master/lib/devise/schema.rb
#which means that if some of the devise methods executed in the above
self.up method are changed this will break
remove_column :users, :encrypted_password
remove_column :users, :password_salt
remove_column :users, :authentication_token
remove_column :users, :confirmation_token
remove_column :users, :confirmed_at
remove_column :users, :confirmation_sent_at
remove_column :users, :reset_password_token
remove_column :users, :remember_token
remove_column :users, :remember_created_at
remove_column :users, :sign_in_count
remove_column :users, :current_sign_in_at
remove_column :users, :last_sign_in_at
remove_column :users, :current_sign_in_ip
remove_column :users, :last_sign_in_ip
remove_column :users, :failed_attempts
remove_column :users, :unlock_token
remove_column :users, :locked_at
end
end
On Wed, Feb 9, 2011 at 2:22 AM, Carlos Antonio da Silva
add_column :users, :encrypted_password, String, :null => null,
:default => default, :limit => 128
:string instead of String?
On Wed, Feb 9, 2011 at 2:33 AM, Carlos Antonio da Silva
add_column :users, :encrypted_password, :string, :limit => 128
class AddDeviseColumnsToUser < ActiveRecord::Migration
def self.up
change_table :users do |t|
#if you already have a email column comment the below line
# t.database_authenticatable
t.confirmable
t.recoverable
t.rememberable
t.trackable
add_column :users, :encrypted_password, :string, :limit => 128
end
end
On Wed, Feb 9, 2011 at 2:42 AM, Carlos Antonio da Silva
Anyway I've created
https://github.com/plataformatec/devise/wiki/How-to:-existing-users-table
The time is 0300 here, I need some sleep. Thanks a lot for the support.
take care,
Seb
On Wed, Feb 9, 2011 at 2:54 AM, Carlos Antonio da Silva
On Wed, Feb 9, 2011 at 3:32 AM, Carlos Antonio da Silva