-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
function version_greater_or_equal() { | ||
[[ "$1" = "$(echo -e "$1\n$2" | sort -V | tail -n 1)" ]] | ||
function version_greater_than() { | ||
[[ "$1" = "$(echo -e "$1\n$2" | sort -V | tail -n 1)" ]] && [[ "$1" != "$2" ]] | ||
} | ||
|
||
function run_migrations() { | ||
echo_title "Starting migrations..." | ||
echo_white | ||
|
||
VERSION=$1 | ||
VERSION_WITHOUT_V="${VERSION#v}" | ||
cd $INFRA_PATH | ||
|
||
euclid_field_version=$(jq -r '.version // empty' "$ROOT_PATH/euclid.json") # Versions previous 0.9.0 doesn't have version field | ||
if version_greater_or_equal $VERSION_WITHOUT_V "0.9.0" || [ -z "$euclid_field_version" ]; then | ||
CURRENT_VERSION=$(jq -r '.version // "0.0.0"' "$ROOT_PATH/euclid.json") | ||
CURRENT_VERSION_WITHOUT_V="${CURRENT_VERSION#v}" | ||
|
||
if version_greater_than "0.9.0" $CURRENT_VERSION_WITHOUT_V; then | ||
echo "Running migration v0.9.0" | ||
cd $SCRIPTS_PATH | ||
source ./migrations/v0.9.0.sh | ||
migrate_v_0_9_0 | ||
VERSION="0.9.0" | ||
current_version="0.9.0" | ||
jq --arg current_version "$current_version" '.version = $current_version' $ROOT_PATH/euclid.json > $ROOT_PATH/temp.json && mv $ROOT_PATH/temp.json $ROOT_PATH/euclid.json | ||
fi | ||
|
||
if version_greater_or_equal $VERSION_WITHOUT_V "0.10.0"; then | ||
if version_greater_than "0.10.0" $CURRENT_VERSION_WITHOUT_V; then | ||
echo "Running migration v0.10.0" | ||
cd $SCRIPTS_PATH | ||
source ./migrations/v0.10.0.sh | ||
migrate_v_0_10_0 | ||
VERSION="0.10.0" | ||
current_version="0.10.0" | ||
jq --arg current_version "$current_version" '.version = $current_version' $ROOT_PATH/euclid.json > $ROOT_PATH/temp.json && mv $ROOT_PATH/temp.json $ROOT_PATH/euclid.json | ||
fi | ||
|
||
# Clean up | ||
rm -r -f $INFRA_PATH/euclid-development-environment 2>/dev/null | ||
rm -f $ROOT_PATH/old-euclid.json 2>/dev/null | ||
contents="$(jq --arg VERSION "$VERSION" ".version = \"$VERSION\"" $ROOT_PATH/euclid.json)" && | ||
echo -E "${contents}" >$ROOT_PATH/euclid.json | ||
|
||
|
||
echo "migrations finished..." | ||
echo | ||
} | ||
} |