ruby on rails - RoR: Cannot change_column in postgres, fine in MySQL (MySQL for development, Postgres on Heroku) -
i had column called "prize":
create_table :contests |t| t.text :prize
i realized integer , wanted set default value:
def change change_column :contests, :prize, :integer, :default => 200
this works fine on local machine, using mysql db. however, when push production site (which hosted on heroku, gives me postgres db) following error:
pgerror: error: column "prize" cannot cast type "pg_catalog.int4" : alter table "contests" alter column "prize" type integer
in article: http://www.postgresonline.com/periodical.php?i_id=3 discuss use of using solve problem. don't know how can that, , whether appropriate i'm trying do.
any insight figuring out appreciated.
thanks! ringo
first should use same db in both environments prevent kind of surprises.
to run raw sql in migrations see example http://guides.rubyonrails.org/migrations.html#using-the-up-down-methods
Comments
Post a Comment