refactor(sqltest): Update init script to support migration editions
This updates the docker image used for tests to support the new location for sql migration files and the concept of editions. It continues to process the old paths for now if the new directory does not exist, so that the same image can be used during the transition.
This commit is contained in:
2 files changed
+30
-7
No files matched your search
@@ -33,7 +33,7 @@ test:
|
||||
-e POSTGRES_PASSWORD=boundary \
|
||||
-e POSTGRES_USER=boundary \
|
||||
-e POSTGRES_DB=boundary \
|
||||
-v "$(CWD)/../schema/migrations/postgres":/migrations \
|
||||
-v "$(CWD)/../schema/migrations":/migrations \
|
||||
-v "$(CWD)/initdb.d":/docker-entrypoint-initdb.d/ \
|
||||
$(POSTGRES_DOCKER_IMAGE)
|
||||
@docker run -it --rm \
|
||||
@@ -56,7 +56,7 @@ database-up:
|
||||
-e POSTGRES_PASSWORD=boundary \
|
||||
-e POSTGRES_USER=boundary \
|
||||
-e POSTGRES_DB=boundary \
|
||||
-v "$(CWD)/../schema/migrations/postgres":/migrations \
|
||||
-v "$(CWD)/../schema/migrations":/migrations \
|
||||
-v "$(CWD)/initdb.d":/docker-entrypoint-initdb.d/ \
|
||||
$(POSTGRES_DOCKER_IMAGE)
|
||||
|
||||
|
||||
@@ -26,8 +26,31 @@ docker_process_sql() {
|
||||
PGHOST= PGHOSTADDR= "${query_runner[@]}" "$@"
|
||||
}
|
||||
|
||||
# Run migrations in order.
|
||||
for file in $(ls -v /migrations/**/*.sql); do
|
||||
echo running "$file"
|
||||
docker_process_sql -f "$file"
|
||||
done
|
||||
if [ -d /migrations/base ]; then
|
||||
# Run migrations in order.
|
||||
for file in $(ls -v /migrations/base/postgres/**/*.up.sql); do
|
||||
echo running "$file"
|
||||
docker_process_sql -f "$file"
|
||||
done
|
||||
|
||||
if [ -d /migrations/oss ]; then
|
||||
# Run migrations in order.
|
||||
for file in $(ls -v /migrations/oss/postgres/**/*.up.sql); do
|
||||
echo running "$file"
|
||||
docker_process_sql -f "$file"
|
||||
done
|
||||
fi
|
||||
|
||||
for d in $(find /migrations/ -mindepth 1 -maxdepth 1 -type d -not -name 'oss' -not -name 'base'); do
|
||||
for file in $(ls -v ${d}/postgres/**/*.up.sql); do
|
||||
echo running "$file"
|
||||
docker_process_sql -f "$file"
|
||||
done
|
||||
done
|
||||
else
|
||||
# Run migrations in order.
|
||||
for file in $(ls -v /migrations/**/*.up.sql); do
|
||||
echo running "$file"
|
||||
docker_process_sql -f "$file"
|
||||
done
|
||||
fi
|
||||
Reference in new issue
Block a user