I had a column called "prize":
create_table :contests do |t|
t.text :prize
I recently realized that this will always be an integer and I wanted to set a default value:
def change
change_column :contests, :prize, :integer, :default => 200
This works fine on my local machine, where I am using MySQL DB. However, when I push to my production site (which is hosted on Heroku, which gives me a Postgres DB) I get the following error:
PGError: ERROR: column "prize" cannot be cast to type "pg_catalog.int4"
: ALTER TABLE "contests" ALTER COLUMN "prize" TYPE integer
In this article: http://www.postgresonline.com/periodical.php?i_id=3 they discuss the use of the USING to solve this problem. But I don't know how I can do that, and whether this is appropriate for what I'm trying to do.
Any insight into figuring this out would be very much appreciated.
Thanks!
Ringo
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…