skip to Main Content

I am trying to use Heroku review apps for testing and demonstrating my site to my colleagues. The site has a large database that will not function with Heroku’s free hobby-dev databases.

I am trying to use the app.json manifest file to specify the platform of my app, as per the guide. The code I’m using is below:

app.json

  {
    "name": "SiteName",
    "description": "The website for SiteName",
    "keywords": [
      "mezzanine",
      "django"
    ],
    "image": "heroku/python",
    "env": {
      "EMAIL_SYSTEM": {
        "description": "The email system to use, either console or mailgun",
        "value": "mailgun"
      },
      "ENVIRONMENT": {
        "description": "The dev environment, either production or test",
        "value": "production"
      },
      "ALLOWED_HOSTS": {
        "description": "Comma-separated list of hosts",
        "value": ".herokuapp.com"
      },
      "DEFAULT_FROM_EMAIL": "[email protected]",
      "SECRET_KEY": {
        "description": "A secret key for verifying the integrity of signed cookies.",
        "generator": "secret"
      },
      "WEB_CONCURRENCY": {
        "description": "The number of processes to run.",
        "value": "5"
      },
      "NODE_ENV": "production",
      "DEBUG": "False",
      "NPM_CONFIG_PRODUCTION": "false",
      "CELERY_REDIS_MAX_CONNECTIONS": 3,
      "S3_BUCKET": "my-s3-bucket",
      "USE_CELERY_TASKS": "True"
    },
    "formation": {
      "web": {
        "quantity": 1,
        "size": "Standard-1X"
      },
      "worker": {
        "quantity": 1,
        "size": "Standard-1X"
      }
    },
    "addons": [
      "heroku-redis",
      {
       "plan": "heroku-postgresql:standard-0",
        "as": "DATABASE"
      }
    ],
    "buildpacks": [
      {
        "url": "https://github.com/heroku/heroku-buildpack-python.git"
      }
    ],
    "scripts": {
      "postdeploy": "python manage.py migrate && python manage.py populate_db"
    },
    "environments": {
      "test": {
        "addons": [
          "heroku-postgresql:in-dyno",
          "heroku-redis:in-dyno"
        ],
        "env": {
          "APP_SKIP_DB_TEARDOWN": "True",
          "DB_REQUIRE_SSL": "False",
          "DEBUG": "True",
          "S3_BUCKET": "my-s3-bucket",
          "USE_CELERY_TASKS": "False"
        },
        "scripts": {
          "test-setup": "python manage.py collectstatic --noinput",
          "test": "python manage.py test"
        }
      }
    }
  }

This will build OK, but how can I explicitly specify the database plan I wish to use?

3

Answers


  1. Chosen as BEST ANSWER

    In case anyone else runs into this.

    According to heroku support they have changed how they provision addons for review and CI apps to mean that by default they'll only provision the free / cheapest plan, regardless of what is in your app.json Here are some details and explanation of their reasoning

    They can override this at an account level if you open a ticket (at time of writing this doesn't seem to be built into their admin area)


  2. You just need to specify the plan using the sintax:
    heroku-postgresql:<plan_you_select>

    "addons": [
            {
              "plan": "heroku-postgresql:<plan_you_select>",
              "as": "DATABASE"
            }
     ]
    

    For a list of the available plans, checkout this link:
    https://devcenter.heroku.com/articles/heroku-postgres-plans#hobby-tier

    You can also use this link: https://elements.heroku.com/addons/heroku-postgresql
    Select a plan on it, and you’ll see the plan name on the CLI
    enter image description here

    Login or Signup to reply.
  3. If you don’t/can’t open a ticket like Pete’s answer suggests, here’s some bash code I just wrote to upgrade my Postgres DB. It’s complicated since:

    • Heroku always starts review apps with a hobby db, ignoring app.json and other settings
    • heroku pg:upgrade only works on non-hobby dbs
    • after creating a new db there’s no simple way to learn its ALL_CAPS name for use in later commands
    # there's no easy way to grab the DATABASE_NAME so we have to grep the output here :-(
    # see https://devcenter.heroku.com/articles/upgrading-heroku-postgres-databases
    # and https://help.heroku.com/SY28FR6H/why-aren-t-i-seeing-the-add-on-plan-specified-in-my-app-json-in-my-review-or-ci-app
    
    echo
    echo "Upgrading Postgres."
    heroku maintenance:on --app $app
    addon_name=`heroku addons:create heroku-postgresql:standard-0 --app $app | grep "is being created" | awk '{print $1}'`
    db_name=`heroku addons:info $addon_name --app $app | grep "Attachments" | awk -F :: '{print $2}'`_URL
    echo $app $addon_name $db_name
    heroku pg:wait --app $app
    heroku pg:copy DATABASE_URL $db_name --app $app --confirm $app
    heroku addons:destroy $addon_name --app $app --confirm $app
    heroku pg:promote $db_name --app $app
    heroku maintenance:off --app $app
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search