If you have an application that requires two PostgreSQL databases, both managed by Clever Cloud, you might have an issue. The naive way to do this would be to link the two PGs addons. But then you would have an issue because the provided environment variables have the same name, so you would only have access to one PG.
Here's a quick and dirty way to manage an additional database automatically.
Whatever you need
LINKED_APPLICATION_ID app_033368e2-c318-4c9b-bd6c-e53010825e86
Link addons -> theFirstDB # link it to the first PostgreSQL instance
CC_PRE_RUN_HOOK="./interpolator.sh" # execute the script that will add the second DB env variables/
CLEVER_SECRET="XXXXXXXXXXXXXX" # the clever secret to login with clever tools
CLEVER_TOKEN="XXXXXXXXXXXXXXXXXXXXX" #the clever token to login with clever tools
PORT="8080"
Link addons -> theSecondDatabase # Link it to the second PostgreSQL instance
Link applications -> theApplicationFor2PGs # Link it to the main app to get its exposed applicationID
#!/bin/bash
clever link $LINKED_APPLICATION_ID
# set the variables for the second DB
clever env set POSTGRESQL_ADDON_DB_2 $POSTGRESQL_ADDON_DB
clever env set POSTGRESQL_ADDON_HOST_2 $POSTGRESQL_ADDON_HOST
clever env set POSTGRESQL_ADDON_PASSWORD_2 $POSTGRESQL_ADDON_PASSWORD
clever env set POSTGRESQL_ADDON_PORT_2 $POSTGRESQL_ADDON_PORT
clever env set POSTGRESQL_ADDON_URI_2 $POSTGRESQL_ADDON_URI
clever env set POSTGRESQL_ADDON_USER_2 $POSTGRESQL_ADDON_USER
clever restart