I created a migration in my development to change the column type from integer to date in my client table.
Migration:
class UpdateGradToDate < ActiveRecord::Migration
def change
change_column :clients, :grad_id, :date
end
end
Which worked fine in development. However, once I push it to Heroku, I got the following error message.
PG::DatatypeMismatch: ERROR: column "grad_id" cannot be cast automatically to type date
HINT: You might need to specify "USING grad_id::date".
: ALTER TABLE "clients" ALTER COLUMN "grad_id" TYPE date
I'm not sure how to correct this problem. I'm thinking perhaps using rails console and changing the column type there but I'm not sure if that's the best solution.
I also tried creating a new migration using using this syntax as well
class ChangeDateFormatInMyTable < ActiveRecord::Migration
def up
change_column :clients, :grad_id, :integer
end
def down
change_column :clients, :grad_id, :date
end
end
I'm not really sure what to do at this point.
grad_idpossibly be a date? Why not just add a new column that makes sense as a date?