Skip to content

Commit d3b2aed

Browse files
feat: Add specific database URL for migrateDb job (#449)
Co-authored-by: Germán Garcés <german.garces@flagsmith.com>
1 parent 6b46efe commit d3b2aed

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

charts/flagsmith/templates/jobs-migrate-db.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ spec:
7171
{{- else }}
7272
args: ["migrate"]
7373
{{- end }}
74-
env: {{ include (print $.Template.BasePath "/_api_environment.yaml") . | nindent 8 }}
74+
env:
75+
{{- include (print $.Template.BasePath "/_api_environment.yaml") . | nindent 8 }}
76+
{{- if and .Values.jobs.migrateDb.databaseUrl .Values.jobs.migrateDb.databaseUrl.fromExistingSecret.enabled }}
77+
{{- /* Override DATABASE_URL with migration-specific credentials */}}
78+
- name: DATABASE_URL
79+
valueFrom:
80+
secretKeyRef:
81+
name: {{ .Values.jobs.migrateDb.databaseUrl.fromExistingSecret.name | required "jobs.migrateDb.databaseUrl.fromExistingSecret.name is required when enabled" }}
82+
key: {{ .Values.jobs.migrateDb.databaseUrl.fromExistingSecret.key | required "jobs.migrateDb.databaseUrl.fromExistingSecret.key is required when enabled" }}
83+
{{- end }}
7584
{{- with .Values.jobs.migrateDb.extraContainers }}
7685
{{ if typeIs "string" . }}
7786
{{- tpl . $ | nindent 6 }}

charts/flagsmith/values.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,17 @@ jobs:
569569
extraVolumes: []
570570
command: []
571571
args: []
572+
# Use separate database credentials for migrations.
573+
# This allows the migration job to run with elevated privileges (e.g., CREATE,
574+
# ALTER, DROP for schema modifications) while the main application uses
575+
# restricted credentials (e.g., SELECT, INSERT, UPDATE, DELETE only).
576+
# This improves security by not granting schema modification privileges to
577+
# the running application.
578+
databaseUrl:
579+
fromExistingSecret:
580+
enabled: false
581+
name: null
582+
key: null
572583
migrateAnalyticsData:
573584
enabled: false
574585
args: []

0 commit comments

Comments
 (0)