Skip to content

Commit

Permalink
Check DB schema version consistency at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-utkin committed Mar 27, 2024
1 parent 3669a9c commit 800d42f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 2 additions & 0 deletions scripts/build_pkg_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ fi
#git submodule foreach --recursive "git clean -dxf && git reset --hard"
#git submodule update --recursive --init

$(dirname $0)/check-db-version-consistency

echo "#define GIT_REVISION \"`git describe --dirty --always --long` `git describe --all`\"" > server/version.h

if [[ $DIST == centos* ]]
Expand Down
14 changes: 14 additions & 0 deletions scripts/check-db-version-consistency
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail

pushd "$(dirname "$0")"/.. >/dev/null

LAST_UPGRADE="$(ls misc/sql/mysql-upgrade | sort -n -r | head -n 1)"
if ! [[ "$(< misc/sql/installed_db_version)" == "$LAST_UPGRADE" ]]; then
cat >&2 <<-EOF
Fix misc/sql/installed_db_version to be $LAST_UPGRADE
echo $LAST_UPGRADE > misc/sql/installed_db_version
git add misc/sql/installed_db_version
EOF
exit 1
fi
10 changes: 1 addition & 9 deletions scripts/git-pre-commit
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
#!/bin/bash
set -euo pipefail

LAST_UPGRADE="$(ls misc/sql/mysql-upgrade | sort -n -r | head -n 1)"
if ! [[ "$(< misc/sql/installed_db_version)" == "$LAST_UPGRADE" ]]; then
cat >&2 <<-EOF
Fix misc/sql/installed_db_version to be $LAST_UPGRADE
echo $LAST_UPGRADE > misc/sql/installed_db_version
git add misc/sql/installed_db_version
EOF
exit 1
fi
$(dirname $0)/check-db-version-consistency

0 comments on commit 800d42f

Please sign in to comment.