Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB_CONNECTION is incorrect when using platform project:init #209

Closed
gilzow opened this issue Mar 4, 2024 · 0 comments · Fixed by #210
Closed

DB_CONNECTION is incorrect when using platform project:init #209

gilzow opened this issue Mar 4, 2024 · 0 comments · Fixed by #210

Comments

@gilzow
Copy link
Contributor

gilzow commented Mar 4, 2024

Line 10 of platformifier/templates/generic/.environment has the following:

{{ if eq .Database "postgresql" }}export DB_CONNECTION="postgresql"{{ else }}export DB_CONNECTION="${{ .DatabaseUpper }}_SCHEME"{{ end }}

However, Platform.sh has not implemented expanded environment variables, so the environment variable of <DATABASENAME>_SCHEME does not exist.

In the case of the following example, DB_CONNECTION ends up being empty since MARIADB_SCHEME does not exist:

export RELATIONSHIPS_JSON="$(echo $PLATFORM_RELATIONSHIPS | base64 --decode)"

# Set database environment variables
export DB_HOST="$(echo $RELATIONSHIPS_JSON | jq -r '.mariadb[0].host')"
export DB_PORT="$(echo $RELATIONSHIPS_JSON | jq -r '.mariadb[0].port')"
export DB_DATABASE="$(echo $RELATIONSHIPS_JSON | jq -r '.mariadb[0].path')"
export DB_USERNAME="$(echo $RELATIONSHIPS_JSON | jq -r '.mariadb[0].username')"
export DB_PASSWORD="$(echo $RELATIONSHIPS_JSON | jq -r '.mariadb[0].password')"
export DB_CONNECTION="$MARIADB_SCHEME"
export DATABASE_URL="${DB_CONNECTION}://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_DATABASE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant