- user should be renamed as "old_users"
- create a new table "user"
- restore the data with different column names in the "user"
rename_table :users, :old_users
create_table :users do |t|
t.column :created_at, :datetime
Temp.find(:all).each do |user|
new_user = User.new(:id=> user.id, :created_at => user.created_at)
Don't worry about the Temp, Temp is a class through which I am accessing the old_users table. Precisely,
class Temp <>
This worked pretty well in my local environment and when I deployed in staging, it crashed. The error was that, it was trying to insert data into table with prvious structure/columns. Which means, the new structure hasn't taken effective.
The quick fix seems to be reset_column_information. Before pushing/creating fresh data in the table, I need to reset the column information of the tables. So including the following line:
right before creating new users solved the problem.
By the way "WISH YOU HAPPY AND PROSPEROUS NEW YEAR"