gitpod/components/gitpod-db/migrate_gcp.sh
2022-12-08 13:05:19 -03:00

23 lines
869 B
Bash
Executable File

#!/bin/bash
# Copyright (c) 2021 Gitpod GmbH. All rights reserved.
# Licensed under the GNU Affero General Public License (AGPL).
# See License.AGPL.txt in the project root for license information.
# This scipt connects via Google's cloud_sql_proxy to a database and runs the db-migrations
# ENV variables for configuration:
# * GOOGLE_APPLICATION_CREDENTIALS_DATA: contents of the crendetials files that cloud_sql_proxy uses for authentication
# * GCP_DATABASE: database name
# * DB_PASSWORD: database password
# Example usage:
# docker run --rm \
# --env GOOGLE_APPLICATION_CREDENTIALS_DATA='...' \
# --env GCP_DATABASE="gitpod-foobar:europe-west1:gitpod-foobar-baz" \
# --env DB_PASSWORD="..." \
# gcr.io/gitpod-core-dev/build/db-migrations:x1 /app/migrate_gcp.sh
set -euo pipefail
/app/typeorm_gcp.sh migrations:run