no such file to load -- sequel/adapters/ and Invalid DATABASE_URL with heroku - postgresql

I am creating a spree application. Now I need to push my local db to heroku shared database. When I ran heroku db:push I got below error
!!! Caught Server Exception
HTTP CODE: 500
Taps Server Error: LoadError: no such file to load -- sequel/adapters/
["/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/core.rb:249:in require'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/core.rb:249:inblock in tsk_require'", "/app/.bundle/gems/ruby/1.9.1/gems/sequel-3.20.0/lib/sequel/core.rb:72:in `block in check_requiring_thread'",
Then I tried to check my shared database url in heroku config. But i didn't found in config vars
Can anyone help me out to solve this issue?

Check that you actually have a Shared Database addon listed when you do;
heroku info
If you don't for whatever reason then you need to do
heroku addons:add shared-database
to add it and then try your push again. Although I can't think why you app wouldn't have the shared db on initial creation.

Related

Error while using pg:push to a Heroku PostgreSQL database

I'm trying to push a local PostgreSQL database to one I've created on a Heroku app. To set up the Heroku database, I ran heroku addons:create heroku-postgresql:hobby-dev -a jasons-react-jobly-app, where jasons-react-jobly-app is the name of my Heroku app.
Then I ran heroku pg:push jobly DATABASE_URL -a jasons-react-jobly-app, where jobly is the name of my local database.
This throws the below error:
heroku-cli: Pushing jobly ---> postgresql-animate-30221
case
------------------------------------
0.9992547478473790.999254747847379
(1 row)
! Cannot read property 'includes' of undefined
The error looks like an error that JavaScript throws when it tries to read properties of an undefined object or something, but I'm not sure where that would be happening in this database push. The app runs completely fine on my local machine with no errors. There is no case column in any of my database tables, so I'm not sure where that number is coming from either.
Also, if I check my Heroku config variables with heroku config, I see:
DATABASE_URL: postgres://iqawqkjfiybndd:c3e921131c239ccd6c880ad4b601deeaa4558339a90ebedc562a5575c9099f42#ec2-54-156-85-145.compute-1.amazonaws.com:5432/dul2u6r13aq5i
So I know the database exists.
Any help with solving this error?
You need to fetch the name of the DB that you see attached to the heroku app on heroku dashboard.
At this url https://dashboard.heroku.com/apps/{put-your-app-name-here}/resources
To get all app names in heroku cli do heroku apps and you will know which app's DB name you want from its dashboard.
Once you have the name of the DB (it will look like this "postgresql-pointy-81624")
use that name in the command to push local db to that db on heroku .
Here are steps to make sure everything works correctly
1- Check the connectivity to the heroku db first by doing
heroku pg:psql postgresql-[somedb name as found above] --app {your-app-name}
2- If it says to reset the DB and you can afford to reset then reset it using
heroku pg:reset -a {your-app-name}
3- Lastly do the migration of DB using this command
heroku pg:push jobly postgresql-[db name found above] -a {your-app-name}
if everything works as expected you will see this message
heroku-cli: Pushing complete.

Heroku Postgres app works on local machine but not on Heroku

I built and deployed a Node.js Postgres app to Heroku and can not get to any of my endpoints via the Heroku site except the root GET route. Curiously, when I run Heroku local web ALL my endpoints behave exactly as they should. I can successfully perform CRUD on the app running via Heroku local web. However, when I try, for instance, to create a user using the Heroku URL, it returns an empty error message. Yet, when I check the associated database I find that the user was indeed created. Other than returning an empty error message when I try to either create a user or sign it, the app correctly responds with the different errors I programmed. For example, when I tweak my login details or try to register the same user I earlier tried to register it correctly says the user already exists!. Still, when I try to log in that same existing user I get a blank error message. Note that I created both the Heroku PostgreSQL database and my local PostgreSQL database from exactly the same queries. Please, can you help me through this bottleneck? I am using Postman to test my APIs.
Test to sign in user on Heroku app running on the local machine: success!
Same exact test with Heroku URL: cryptic error.
Ok, so after a lot of researching and fiddling around I discovered the solution. I did not add keys from my .env file to Heroku as config vars found under the settings tab of the Heroku User dashboard. Manually adding my environment variables resolved the matter. Now my app is working both on my local machine and via the Heroku URL.

Heroku Postgresql Database

I have created database in heroku hobby-dev and uploaded table from postgresql and used app.db.create_all() to trigger database model but its showing psycopg2 wheel package will be renamed from release 2.8 and suggesting us to install psycopg2-binary and we installed that too and still app.db.create_all() not working.
The error doesn't relate to database Integration. There should be some error in Backend that's why It's giving 500.
For checking the error in heroku logs using heroku cli, use this :
heroku logs -t
Alternatively, you can view the logs on the App dashboard.
I hope this helps.

Heroku database restore issue

Have gone through different solutions available on stackoverflowand also on different forums. But none addresses the precise problem.
As per the documentation: https://devcenter.heroku.com/articles/heroku-postgres-import-export
I have the dump file created from my local database, with this command:
pg_dump -Fc --no-acl --no-owner -h localhost -U postgres dss_iaya>dss_iaya_db_dump1.dump
Then as per documentation, uploaded to a server with public access URL: https://firebasestorage.googleapis.com/v0/b/iaya-664f3.appspot.com/o/dss_iaya_db_dump1.dump?alt=media&token=06167d04-1e98-4e4b-b0e0-9d83a86dd167
Now when I try to restore on Heroku as per its documentation syntax heroku pg:backups:restore [BACKUP] [DATABASE] --app APP using following command, it returns error message when restoring.
heroku pg:backups:restore --app heroku-postgres-*** 'https://firebasestorage.***/dss_iaya_db_dump1.dump?alt=media&token=***' 'postgres://quesu***:I***#ec2-54-***.eu-west-1.compute.amazonaws.com:5432/d3n***k0'
I have used *** for security purpose only, as can not mention full credentials. But I believe one can understand the whole syntax.
When I restore same .dump file on a newly created local database it works without any issues and creates/restores the whole database with tables and data.
Just found the solution, actually two things were wrong in my case.
One, the uploaded .dump file was not well readable/usable by the heroku.
Two, the heroku postgresql DB complete URL was not required to be provided.
So, the right way that worked for me was that the uploaded file should be accessible without any token and also without any virtual/indirect path, etc. The URL to the file should point to the file directly. In my questioned problem, I was using firebase to host my DB file temporarily to do the heroku operation. And firebase was not giving direct URL to the uploaded physical file.
heroku pg:backups:restore --app heroku-postgres-f3*** 'https://www.h***.com/dss_iaya_db_dump2.dump' DATABASE_URL
After typing this command, I was asked to retype the heroku app name just to confirm the operation. Once done, everything worked like a charm.
In logs you see dump size: 0 Bytes. Also you see aborting and 403,
so if you check your file: https://llfirebasestorage.googleapis.com/vo/b/iaya-664f3.appspot.com/0/dss_iaya_db_dump1.dump?a1t=media
you get:
404. That’s an error.
The requested URL /vo/b/iaya-664f3.appspot.com/0/dss_iaya_db_dump1.dump was not found on
this server. That’s all we know.

How do I roll back a heroku pg:promote command?

I called heroku pg:promote HEROKU_POSTGRESQL_BROWN_URL on my Heroku app, and now it's giving me an application error when I try to load it. How do I reverse this command?
Just promote your other database back (if it were copper):
pg:promote HEROKU_POSTGRESQL_COPPER_URL