ss_millionaire
ss_millionaire

Reputation: 429

Heroku Review App Cannot find Database

I have a Django app, which uses a postgres database hosted on heroku. I'm trying to create a review app based on this Django app. However, I can't seem to access my DB on the review app. I've added a postdeploy script as shown in the app.json below but it doesn't seem to solve it:

{
   "name": "bookapp",
   "scripts": {
      "postdeploy": "pg_dump $DATABASE_URL | psql $DATABASE_URL && python 
       ./manage.py migrate"
    },

   "env": {
     "DATABASE_URL": {
       "required": true
     },
     "QV_CLOUDINARY_API_KEY": {
        "required": true
     },
     "QV_CLOUDINARY_API_SECRET": {
        "required": true
      },
     "QV_CLOUDINARY_CLOUD_NAME": {
        "required": true
      },
     "QV_DATABASE_NAME": {
         "required": true
      },
     "QV_DATABASE_PASSWORD": {
        "required": true
      },
     "QV_DATABASE_USER": {
        "required": true
      },
     "QV_SECRET_KEY": {
        "required": true
      }
   },
   "formation": {
      "web": {
        "quantity": 1
      }
    },
   "addons": [
      "heroku-postgresql"
    ],
   "buildpacks": [
     {
       "url": "heroku/python"
     }
   ]
}

Upvotes: 0

Views: 422

Answers (1)

ss_millionaire
ss_millionaire

Reputation: 429

Found the solution!.

The app.json file above is correct. Apparently the post-deploy script only runs the first time the app is created. I had to close the Pull Request for the review app and re-open a new one so that a new review app is created. Doing that executed the post-deploy script and i was able to access my DB.

Upvotes: 1

Related Questions