Reputation: 183
I'm running two projects as a different repository with git. One is admit another one is Web
in rails, both are connected with each other, Basically same database is used. I only made the migration on admin report and then cloned it into the web. The problem is, I'm deploying it on the server and test cases failed the error says
ActionView::Template::Error: PG::UndefinedColumn: ERROR: column fees.discount does not exist
I just don't understand why it has been happening, in admin I have that field presents.
I think schema.rb may playing role in this case. I'm not so sure about it.
Here is my migration,
class AddDiscountToFeel < ActiveRecord::Migration[5.0]
def change
add_column :fees, :discount, :integer, default: nil, null: true
end
end
And here is my Model fields in development:
2.3.1 :008 > Fee.column_names
=> ["id", "booth_id", "amount", "description", "created_at", "updated_at", "discount"]
And here is my Model fields in test:
C238s-iMac:web c238$ RAILS_ENV=test rails c
Loading test environment (Rails 5.0.0.1)
2.3.1 :001 > Fee.column_names
=> ["id", "booth_id", "amount", "description", "created_at", "updated_at", "discount"]
And here is my error's snap:
Any help will be appreciated.
Upvotes: 1
Views: 458
Reputation: 183
Yes, I was right
It has been long time in web that I haven’t updated schema from admin that’s why I’ve faced this issue.
Solution: Copied schema.rb
from admin into web repo, because both projects use same DB.
May the answer will helpful for someone also.
Upvotes: 1
Reputation: 3376
Can try to run to add discount
to the table?
bundle exec rake db:migrate
if using heroku:
heroku run rake db:migrate
Upvotes: 0