heroku and db migration
class AddExpMonthAndExpYearToOrder < ActiveRecord::Migration
def self.up
add_column :orders, :exp_month, :integer
add_column :orders, :exp_year, :integer
end
def self.down
remove_column :orders, :exp_month
remove_column :orders, :exp_year
end
end
Have this migration, running it on heroku, but nothing changes. New fields doesnt appears in the table. Dunno where is a problem
Ruby console for sample.heroku.com
>> Order
=> Order(id: integer, ship_address: string, city: string, state: string, zip: string, cc_number: string, telephone: string, cart_id: integer, created_at: datetime, updated_at: datetime)
>> exit
petya:geomarket > heroku rake db:migrate
(in /app)
== AddExpMonthAndExpYearToOrder: migrating ===================================
-- add_column(:orders, :exp_month, :integer)
-> 0.0025s
-- add_column(:orders, :exp_year, :integer)
-> 0.0017s
== AddExpMonthAndExpYearToOrder: migrated (0.0044s) ==========================
petya:geomarket > heroku console
Ruby console for sample.heroku开发者_高级运维.com
>> Order
=> Order(id: integer, ship_address: string, city: string, state: string, zip: string, cc_number: string, telephone: string, cart_id: integer, created_at: datetime, updated_at: datetime)
On my local machine all works fine. Tried to remigrate, didnt help.
If you have your DB setup locally the way you want it, and you simply want to mirror that data/schema on Heroku, try heroku db:push
Good luck!
heroku changed their api a bit
heroku run rake db:migrate
solves it for me
I just had the same problem.
Heroku is very strickt with migration naming. Try to add a 's' to the Class name as well as the filename and you will see that it works.
It worked for me, so maybe that will solve your problem as well.
精彩评论