Hello, please tell me how to fix this error?

max-PC% heroku run rake db:migrate Running rake db:migrate on maxprof-cinema... up, run.8028 == 20160428140718 ChangeDateFieldTypeBack: migrating ========================== -- change_column(:film_sessions, :date, :date) rake aborted! StandardError: An error has occurred, this and all later migrations canceled: PG::DatatypeMismatch: ERROR: column "date" cannot be cast automatically to type date HINT: You might need to specify "USING date::date". ALTER TABLE "film_sessions" ALTER COLUMN "date" TYPE date 

I do not understand where to register it: USING date::date

Falling migration:

 class ChangeDateFieldTypeBack < ActiveRecord::Migration def change change_column(:film_sessions, :date, :date) end end 
  • I added a migration code) I have no idea why everything is local locally, but problems start on the server .. Please tell me ) - Maxim Cherevatov
  • This is not the migration. - D-side
  • Exactly, updated question - Maxim Cherevatov
  • What kind of database do you have locally? - D-side
  • sqlite3 - standard - Maxim Cherevatov

1 answer 1

According to McAndra Cards , in-it goes there:

 change_column :film_sessions, :date, 'date USING "date"::date' # это на всякий случай, date же является типом ^ ^ 

... this is a blatant exploitation of the SQL syntax features, and even a specific dialect, so you should not expect it to work anywhere other than PostgreSQL (even in SQLite!).

And if SQLite is allowed to do this implicitly, this is a stone in the SQLite garden, since the conversion from string to date generally loses data .