Skip to content

Commit feb9de2

Browse files
committed
Refactor migrations to use external ConfigMap instead of chart-embedded SQL files
1 parent 7e50bff commit feb9de2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

charts/supabase/templates/db/statefulset.yaml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@ spec:
4848
4949
echo "Copying user-defined migration scripts..."
5050
cp /custom-migrations/* /initdb.d/migrations/ || echo "Skip migrations"
51+
{{- if and .Values.db.migrations.enabled .Values.db.migrations.existingConfigMap }}
52+
echo "Copying external migrations from ConfigMap..."
53+
cp {{ .Values.db.migrations.mountPath }}/* /initdb.d/migrations/ || echo "No external migrations found"
54+
{{- end }}
5155
echo "Initialization scripts are ready"
5256
volumeMounts:
5357
- mountPath: /custom-init-scripts
5458
name: custom-init-scripts
55-
- mountPath: /custom-migrations
59+
{{- if and .Values.db.migrations.enabled .Values.db.migrations.existingConfigMap }}
60+
- mountPath: {{ .Values.db.migrations.mountPath }}
5661
name: custom-migrations
62+
{{- end }}
5763
- mountPath: /initdb.d
5864
name: initdb-scripts-data
5965
containers:
@@ -158,6 +164,11 @@ spec:
158164
- name: custom-migrations
159165
configMap:
160166
name: {{ include "supabase.db.fullname" . }}-migrations
167+
{{- if and .Values.db.migrations.enabled .Values.db.migrations.existingConfigMap }}
168+
- name: user-migrations
169+
configMap:
170+
name: {{ .Values.db.migrations.existingConfigMap }}
171+
{{- end }}
161172
{{- with .Values.db.volumes }}
162173
{{- toYaml . | nindent 8 }}
163174
{{- end }}

charts/supabase/values.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ db:
183183
affinity: {}
184184
# Additional migration scripts can be defined here
185185
config: {}
186+
# Database migrations from external ConfigMap
187+
# Users should create ConfigMap before installing the chart:
188+
# kubectl create configmap my-migrations --from-file=./migrations/ -n namespace
189+
migrations:
190+
# Enable mounting external migrations ConfigMap
191+
enabled: true
192+
# Name of existing ConfigMap containing migration SQL files
193+
existingConfigMap: "custom-migrations"
194+
# Mount path for migrations in init container
195+
mountPath: /custom-migrations
186196

187197
# Studio Application
188198
studio:

0 commit comments

Comments
 (0)