Simon Cooper
Simon Cooper

Reputation: 1594

Local postrges works, but can't seem to push to RAILS_ENV=production heroku

I have my app working just fine on my local environment at localhost:3000. It is pulling data from my local postgres db, however I don't appear to be updating the production environment. My welcome page is viewable on my https://gcl.herokuapp.com page, but when I click the nav link to view another page I get an error, I'm assuming because that page calls on data from the db, which it cannot find.

I'm doing $ rails db:migrate RAILS_ENV=production

I get the following output in Terminal:

(0.2ms)  SELECT pg_try_advisory_lock(3666737882978712990);
ActiveRecord::SchemaMigration Load (0.6ms)  SELECT "schema_migrations".* 
FROM "schema_migrations"
ActiveRecord::InternalMetadata Load (0.6ms)  SELECT  
"ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2  [["key", :environment], ["LIMIT", 1]]
(0.2ms)  BEGIN
SQL (1.9ms)  UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3  [["value", "production"], ["updated_at", 2017-03-31 10:42:57 UTC], ["key", "environment"]]
(0.4ms)  COMMIT
(0.2ms)  SELECT pg_advisory_unlock(3666737882978712990)

I have gem 'pg' in my Gemfile

My database.yml looks like:

default: &default
 adapter: postgresql
 pool: 5
 timeout: 5000

development:
 adapter: postgresql
 database: postgresql-rectangular-42683
 pool: 5
 timeout: 5000
test:
 adapter: postgresql
 database: postgresql-rectangular-42683
 pool: 5
 timeout: 5000

production:
 adapter: postgresql
 database: postgresql-rectangular-42683
 username: Simon
 password: *************

 pool: 5
 timeout: 5000`

Any thoughts? Been trying various things for about a day now :(

Simon

Upvotes: 0

Views: 499

Answers (2)

Simon Cooper
Simon Cooper

Reputation: 1594

Haha, two mins later I've found what the problem was, and as usual it was a simple one. I needed to run $ heroku run rake db:seed.

Although this only seems to have added the tables, as my rows still show as 0 of 10000

Also, my pages still don't load at https://gcl.herokuapp.com/articles but not 100% sure that's related to the db.

Upvotes: 0

amrrbakry
amrrbakry

Reputation: 599

Try this in the terminal:

heroku run rake db:create:all

then run the migrations:

heroku run rake db:migrate

Also, could you post the output of heroku logs

Upvotes: 4

Related Questions