fix: use configurable db username in dbinit job instead of hardcoded root
Root user doesn't have access on external DB. Now uses the same database username helper as the main deployment. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e7899972e2
commit
53d86cd48b
@ -50,12 +50,12 @@ spec:
|
||||
- name: MYSQL_DATABASE
|
||||
value: {{ include "hades.databaseName" . | quote }}
|
||||
- name: MYSQL_USER
|
||||
value: "root"
|
||||
value: {{ include "hades.databaseUsername" . | quote }}
|
||||
- name: MYSQL_PWD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: {{ include "hades.databaseSecretName" . }}
|
||||
key: mysql-root-password
|
||||
key: mysql-password
|
||||
command:
|
||||
- /bin/bash
|
||||
- -c
|
||||
@ -72,7 +72,7 @@ spec:
|
||||
|
||||
# Test connection
|
||||
echo "Testing database connection..."
|
||||
if ! mysql -h"${MYSQL_HOST}" -P"${MYSQL_PORT}" -u"root" -e "SELECT 1" "${MYSQL_DATABASE}" &> /dev/null; then
|
||||
if ! mysql -h"${MYSQL_HOST}" -P"${MYSQL_PORT}" -u"${MYSQL_USER}" -e "SELECT 1" "${MYSQL_DATABASE}" &> /dev/null; then
|
||||
echo "ERROR: Cannot connect to database"
|
||||
exit 1
|
||||
fi
|
||||
@ -94,7 +94,7 @@ spec:
|
||||
|
||||
echo -n "Applying $filename... "
|
||||
|
||||
if mysql -h"${MYSQL_HOST}" -P"${MYSQL_PORT}" -u"root" "${MYSQL_DATABASE}" < "$sql_file" 2>/tmp/migration_error.log; then
|
||||
if mysql -h"${MYSQL_HOST}" -P"${MYSQL_PORT}" -u"${MYSQL_USER}" "${MYSQL_DATABASE}" < "$sql_file" 2>/tmp/migration_error.log; then
|
||||
echo "✓ SUCCESS"
|
||||
SUCCESS=$((SUCCESS + 1))
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user