PG :: UndefinedColumn: ERROR in case of the same database is used for two different projects that are related to each other in Rails

I am running two projects as another repository with git. One of them admits that in rails of the other Web , both are connected to each other, basically the same database is used. I just migrated according to the administratorโ€™s report, and then cloned it to the network. The problem is that I am deploying it to the server, and the test cases failed.

 ActionView::Template::Error: PG::UndefinedColumn: ERROR: column fees.discount does not exist 

I just donโ€™t understand why this is happening, in admin I have this field.

I think schema.rb might play a role in this case. I am not sure about that.

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 are my Model fields in development :

  2.3.1 :008 > Fee.column_names => ["id", "booth_id", "amount", "description", "created_at", "updated_at", "discount"] 

And here are my Model fields in the 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 mistake:

enter image description here

Any help would be appreciated.

+5
source share
2 answers

Yes i was right

The web browser has not had an updated scheme from the administrator for a long time, so I ran into this problem.

Solution: Copied schema.rb from the administrator to the web repo, because both projects use the same database.

Perhaps the answer will be useful for someone.

+4
source

Can I try to run to add discount to the table? bundle exec rake db:migrate

if you use a hero: heroku run rake db:migrate

0
source

Source: https://habr.com/ru/post/1273421/


All Articles