Skip to content

Instantly share code, notes, and snippets.

@ayushgp
Last active March 11, 2021 02:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayushgp/fa9c0c7f6f2d45a26b25bba4df32b07b to your computer and use it in GitHub Desktop.
Save ayushgp/fa9c0c7f6f2d45a26b25bba4df32b07b to your computer and use it in GitHub Desktop.
Take Hasura migrations from one server and apply them to another
# Take Hasura migrations from staging and apply them to prod
# Usage: ./migrate.sh "<staging-endpoint>" "<staging-secret>" "<prod-endpoint>" "<prod-secret>" "<migration-name>"
STAGING_ENDPOINT="$1"
STAGING_SECRET="$2"
PROD_ENDPOINT="$3"
PROD_SECRET="$4"
MIGRATION_NAME="$5"
# Create migrations and metadata exports using staging env after changes
hasura migrate create $MIGRATION_NAME --from-server --endpoint $STAGING_ENDPOINT --admin-secret $STAGING_SECRET
hasura metadata export --endpoint $STAGING_ENDPOINT --admin-secret $STAGING_SECRET
# Apply migrations to prod
hasura migrate apply --endpoint $PROD_ENDPOINT --admin-secret $PROD_SECRET
hasura metadata apply --endpoint $PROD_ENDPOINT --admin-secret $PROD_SECRET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment