github.com/status-im/status-go@v1.1.0/_assets/scripts/migration_check.sh (about) 1 #!/usr/bin/env bash 2 3 set -e 4 set -o pipefail 5 6 check_migration_order() { 7 local prev_migration="" 8 for file in "$@"; do 9 current_migration=$(echo "$file" | cut -d'-' -f1) 10 11 if [[ ! -z "$prev_migration" && "$current_migration" < "$prev_migration" ]]; then 12 echo "migration ${current_migration} is not in order with ${prev_migration}" 13 echo "Error: Migration files are out of order. Please ensure migrations are added in chronological order." 14 exit 1 15 fi 16 17 prev_migration="$current_migration" 18 done 19 } 20 21 git checkout origin/develop 22 git pull origin develop 23 git checkout - 24 committed_files=$(git ls-tree -r --name-only HEAD protocol/migrations/sqlite/*.sql | sort) 25 staged_files=$(git diff --name-only origin/develop protocol/migrations/sqlite/*.sql | sort) 26 27 all_files=$(echo -e "$committed_files\n$staged_files") 28 29 # protocol migrations 30 check_migration_order $all_files 31 32 committed_files=$(git ls-tree -r --name-only HEAD appdatabase/migrations/sql/*.sql | sort) 33 staged_files=$(git diff --name-only origin/develop appdatabase/migrations/sql/*.sql | sort) 34 35 all_files=$(echo -e "$committed_files\n$staged_files") 36 37 # account migrations 38 check_migration_order $all_files 39 40 committed_files=$(git ls-tree -r --name-only HEAD protocol/encryption/migrations/sqlite/*.sql | sort) 41 staged_files=$(git diff --name-only origin/develop protocol/encryption/migrations/sqlite/*.sql | sort) 42 43 all_files=$(echo -e "$committed_files\n$staged_files") 44 45 # encryption migrations 46 check_migration_order $all_files 47 48 exit 0