This repository has been archived by the owner on Feb 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: better database migrations - managed by supabase (#570)
* chore: move api migrations into dedicated container for k8s job * chore: move ui migrations into dedicated container for k8s job * chore: add migration containers to the release workflow
- Loading branch information
Showing
21 changed files
with
141 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: api-migrations-{{ .Values.image.lfaiAPITag }} | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: supabase-cli | ||
image: "ghcr.io/defenseunicorns/leapfrogai/api-migrations:{{ .Values.image.lfaiAPITag }}" | ||
env: | ||
- name: POSTGRES_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: supabase-postgresql | ||
key: postgres-password | ||
- name: MIGRATION_NAMESPACE | ||
value: "{{ .Values.api.migration.namespace }}" | ||
- name: MIGRATION_SERVICE_NAME | ||
value: "{{ .Values.api.migration.serviceName }}" | ||
- name: MIGRATION_SERVICE_PORT | ||
value: "{{ .Values.api.migration.servicePort }}" | ||
|
||
# NOTE: This command is assuming the default username. | ||
command: ["/bin/sh"] | ||
args: | ||
- -c | ||
- >- | ||
supabase migration fetch --db-url="postgresql://postgres:$POSTGRES_PASSWORD@$MIGRATION_SERVICE_NAME.$MIGRATION_NAMESPACE.svc.cluster.local:$MIGRATION_SERVICE_PORT" --debug || true && | ||
supabase db push --db-url="postgresql://postgres:$POSTGRES_PASSWORD@$MIGRATION_SERVICE_NAME.$MIGRATION_NAMESPACE.svc.cluster.local:$MIGRATION_SERVICE_PORT" --debug | ||
restartPolicy: Never | ||
backoffLimit: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM --platform=$TARGETPLATFORM cgr.dev/chainguard/bash:latest | ||
ARG TARGETPLATFORM | ||
ARG version="1.169.8" | ||
|
||
# Download the supabase cli | ||
RUN mkdir -p /usr/local/bin | ||
RUN ARCH=$(echo $TARGETPLATFORM | cut -d '/' -f2) \ | ||
&& curl -LO https://github.com/supabase/cli/releases/download/v${version}/supabase_linux_${ARCH}.tar.gz \ | ||
&& tar -xzf supabase_linux_${ARCH}.tar.gz -C /usr/local/bin/ \ | ||
&& rm supabase_linux_${ARCH}.tar.gz | ||
|
||
# 65532 is the UID of the `nonroot` user in chainguard/static. See: https://edu.chainguard.dev/chainguard/chainguard-images/reference/static/overview/#users | ||
USER 65532:65532 | ||
|
||
# Download the migration scripts | ||
COPY --chown=65532:65532 migrations/*.sql supabase/migrations/ |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 0 additions & 18 deletions
18
packages/supabase/migrations/20240322174520_api_sql_schema.sql
This file was deleted.
Oops, something went wrong.
55 changes: 0 additions & 55 deletions
55
packages/supabase/migrations/20240322174521_ui_sql_schema.sql
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
packages/supabase/migrations/20240522134301_profile_0.8_migration.sql
This file was deleted.
Oops, something went wrong.
30 changes: 0 additions & 30 deletions
30
packages/supabase/migrations/20240523233951_0.8_ui_migration.sql
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: ui-migrations-{{ .Values.image.tag }} | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: supabase-cli | ||
image: "ghcr.io/defenseunicorns/leapfrogai/ui-migrations:{{ .Values.image.tag }}" | ||
env: | ||
- name: POSTGRES_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: supabase-postgresql | ||
key: postgres-password | ||
- name: MIGRATION_NAMESPACE | ||
value: "{{ .Values.migration.namespace }}" | ||
- name: MIGRATION_SERVICE_NAME | ||
value: "{{ .Values.migration.serviceName }}" | ||
- name: MIGRATION_SERVICE_PORT | ||
value: "{{ .Values.migration.servicePort }}" | ||
|
||
# NOTE: This command is assuming the default username. | ||
command: ["/bin/sh"] | ||
args: | ||
- -c | ||
- >- | ||
supabase migration fetch --db-url="postgresql://postgres:$POSTGRES_PASSWORD@$MIGRATION_SERVICE_NAME.$MIGRATION_NAMESPACE.svc.cluster.local:$MIGRATION_SERVICE_PORT" --debug || true && | ||
supabase db push --db-url="postgresql://postgres:$POSTGRES_PASSWORD@$MIGRATION_SERVICE_NAME.$MIGRATION_NAMESPACE.svc.cluster.local:$MIGRATION_SERVICE_PORT" --debug | ||
restartPolicy: Never | ||
backoffLimit: 4 |
Oops, something went wrong.