2020-06-24 13:38:48 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -evo pipefail
|
|
|
|
IFS=$'\n\t'
|
|
|
|
ROOT="$(readlink -f ${BASH_SOURCE[0]%/*}/../../)"
|
|
|
|
|
|
|
|
wait_for_server() {
|
|
|
|
echo "waiting for server"
|
|
|
|
for _ in $(seq 1 60);
|
|
|
|
do
|
2023-02-16 22:54:19 +03:00
|
|
|
docker run --rm --network container:graphql-engine curlimages/curl http://127.0.0.1:8080/v1/version && return
|
2020-06-24 13:38:48 +03:00
|
|
|
echo -n .
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
echo "Failed waiting for server" && exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# get previous stable version docker-compose file
|
|
|
|
curl -L https://raw.githubusercontent.com/hasura/graphql-engine/stable/install-manifests/docker-compose/docker-compose.yaml -o docker-compose-latest.yaml
|
|
|
|
sed -i '/hasura\/graphql-engine:/ s/$/.cli-migrations-v2\n container_name: graphql-engine/' docker-compose-latest.yaml
|
|
|
|
# start postgres
|
2023-06-08 17:04:10 +03:00
|
|
|
docker compose -f docker-compose-latest.yaml up --no-start graphql-engine
|
2020-06-24 13:38:48 +03:00
|
|
|
# copy migrations directory to /hasura-migrations
|
|
|
|
docker cp migrations/. graphql-engine:/hasura-migrations
|
|
|
|
# copy metadata directory to /hasura-metadata
|
|
|
|
docker cp metadata/. graphql-engine:/hasura-metadata
|
|
|
|
# start graphql-engine
|
2023-06-08 17:04:10 +03:00
|
|
|
docker compose -f docker-compose-latest.yaml up -d --no-recreate graphql-engine
|
2020-06-24 13:38:48 +03:00
|
|
|
wait_for_server
|
|
|
|
# export metadata and run diff with validation/metadata.json
|
2023-02-16 22:54:19 +03:00
|
|
|
docker run --rm --network container:graphql-engine curlimages/curl -s -f -d'{"type" : "export_metadata", "args" : {} }' localhost:8080/v1/query | jq -j '.' | diff validation/metadata.json -
|
2020-06-24 13:38:48 +03:00
|
|
|
# get list of migrations applied from graphql-engine server
|
2023-02-16 22:54:19 +03:00
|
|
|
docker run --rm --network container:graphql-engine curlimages/curl -s -f -d'{"type" : "run_sql", "args" : {"sql": "select * from hdb_catalog.schema_migrations"} }' localhost:8080/v1/query | jq -j '.' | diff validation/schema_migrations.json -
|
2020-06-24 13:38:48 +03:00
|
|
|
|
|
|
|
# use the current build to start container
|
2023-06-08 17:04:10 +03:00
|
|
|
docker compose up -d
|
2020-06-24 13:38:48 +03:00
|
|
|
wait_for_server
|
|
|
|
# export metadata and run diff with validation/metadata.json
|
2023-02-16 22:54:19 +03:00
|
|
|
docker run --rm --network container:graphql-engine curlimages/curl -s -f -d'{"type" : "export_metadata", "args" : {} }' localhost:8080/v1/query | jq -j '.' | diff validation/metadata.json -
|
2020-06-24 13:38:48 +03:00
|
|
|
# get list of migrations applied from graphql-engine server
|
2023-02-16 22:54:19 +03:00
|
|
|
docker run --rm --network container:graphql-engine curlimages/curl -s -f -d'{"type" : "run_sql", "args" : {"sql": "select * from hdb_catalog.schema_migrations"} }' localhost:8080/v1/query | jq -j '.' | diff validation/schema_migrations.json -
|
2020-06-24 13:38:48 +03:00
|
|
|
# delete postgres and graphql-engine
|
2023-06-08 17:04:10 +03:00
|
|
|
docker compose down -v
|