feat: automate business upgrades and sync reviewed frontend
This commit is contained in:
+13
-2
@@ -73,6 +73,17 @@ rollback() {
|
||||
result=$?
|
||||
trap - ERR
|
||||
set +eu
|
||||
# A successful schema/data upgrade cannot be undone by switching images.
|
||||
# Probe the old binary before letting it touch the upgraded database.
|
||||
if exists sw2-backend-previous; then
|
||||
previous_image=$(docker inspect --format '{{.Config.Image}}' sw2-backend-previous)
|
||||
if ! docker run --rm --network "$NETWORK" --env-file "$BASE_DIR/runtime.env" \
|
||||
-v "$BASE_DIR/config:/data/conf:ro" -v "$BASE_DIR/log:/app/logs" \
|
||||
"$previous_image" /app/kratos-admin -conf /data/conf/config.yaml -check-schema; then
|
||||
echo 'Deployment failed after a database change. Upgrade state/backups and current containers are retained; the incompatible previous backend stays stopped. Redeploying resumes the database upgrade.' >&2
|
||||
exit "$result"
|
||||
fi
|
||||
fi
|
||||
for name in "${created[@]}"; do docker rm -f "$name" >/dev/null 2>&1; done
|
||||
for name in "${moved[@]}"; do
|
||||
if exists "$name-previous"; then docker rename "$name-previous" "$name"; fi
|
||||
@@ -91,10 +102,10 @@ for name in "${NAMES[@]}"; do
|
||||
fi
|
||||
done
|
||||
|
||||
echo 'Applying and verifying database migrations before starting the service.'
|
||||
echo 'Automatically converting, migrating, verifying and cleaning the business database before starting the service.'
|
||||
docker run --rm --name sw2-migrate --label com.sw2.application=sw2 \
|
||||
--network "$NETWORK" --env-file "$BASE_DIR/runtime.env" \
|
||||
-v "$BASE_DIR/config:/data/conf:ro" -v "$BASE_DIR/log:/app/logs" \
|
||||
-v "$BASE_DIR/config:/data/conf" -v "$BASE_DIR/log:/app/logs" \
|
||||
"$BACKEND_IMAGE" /app/kratos-admin -conf /data/conf/config.yaml -migrate
|
||||
|
||||
created+=(sw2-backend)
|
||||
|
||||
Reference in New Issue
Block a user