So you have a Google Cloud SQL running postgres and you want to use it on Heroku. No problem. I'll walk you through how to do it with a rails application.
From your terminal using the Heroku CLI
heroku buildpacks:add --index=1 https://github.com/lukelove/heroku-buildpack-cloud-sql-proxy.git
Follow the Setup and installation for this buildpack making sure to add all of the env variables to your project.
Your Procfile should look something like this.
web: bin/run_cloud_sql_proxy &>null && bundle exec rails server -p $PORT
rake: bin/run_cloud_sql_proxy &>null && rake
rails: bin/run_cloud_sql_proxy &>null && bundle exec rails
Make sure that the bin/run_cloud_sql_proxy is always run before your desired actions. This will enable you to run things like normal ie:
> heroku run rails console
> heroku run rake db:migrate
Remove the production environment from config/database.yml which forces heroku to use the DATABASE_URL env variable.
If you just created a new app, Heroku automatically assigns it a database and sets the DATABASE_URL. If it's appropriate for you, remove the empty database from the Heroku project resources since you'll be using the Google Cloud SQL anyways.