mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 03:57:51 +02:00
Cover more base in forbidden SQL change check (#785)
* Cover more base in forbidden SQL change check Update the forbidden SQL change detection script to include file deletion and renaming as well as edits.
This commit is contained in:
parent
0e685940d8
commit
09dd6580d2
2 changed files with 13 additions and 6 deletions
|
@ -26,9 +26,14 @@ Checks for post-deployment change to Flyway scripts.
|
||||||
|
|
||||||
With Flyway, once an incremental change script is deployed, it must not be
|
With Flyway, once an incremental change script is deployed, it must not be
|
||||||
changed. Even changes to comments or whitespaces would cause validation
|
changed. Even changes to comments or whitespaces would cause validation
|
||||||
failures during future deployment. This script checks for changes to scripts
|
failures during future deployment. This script checks for changes (including
|
||||||
that have already been deployed to Sandbox. The assumption is that the schema
|
removal and renaming which may happen due to incorrect merge conflict
|
||||||
in Sandbox is always newer than that in production.
|
resolution) to scripts that have already been deployed to Sandbox. The
|
||||||
|
assumption is that the schema in Sandbox is always newer than that in
|
||||||
|
production.
|
||||||
|
|
||||||
|
A side-effect of this check is that old branches missing recently deployed
|
||||||
|
scripts must update first.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-h, --help show this help text
|
-h, --help show this help text
|
||||||
|
@ -61,7 +66,7 @@ fi
|
||||||
sandbox_tag=$(fetchVersion sql sandbox ${DEV_PROJECT})
|
sandbox_tag=$(fetchVersion sql sandbox ${DEV_PROJECT})
|
||||||
echo "Checking Flyway scripts against schema in Sandbox (${sandbox_tag})."
|
echo "Checking Flyway scripts against schema in Sandbox (${sandbox_tag})."
|
||||||
modified_sqls=$(git diff --name-status ${sandbox_tag} \
|
modified_sqls=$(git diff --name-status ${sandbox_tag} \
|
||||||
db/src/main/resources/sql/flyway | grep ^M | grep \.sql$ | wc -l)
|
db/src/main/resources/sql/flyway | grep "^M\|^D\|^R" | grep \.sql$ | wc -l)
|
||||||
|
|
||||||
if [[ ${modified_sqls} = 0 ]]; then
|
if [[ ${modified_sqls} = 0 ]]; then
|
||||||
echo "No illegal change to deployed schema scripts."
|
echo "No illegal change to deployed schema scripts."
|
||||||
|
@ -69,6 +74,7 @@ if [[ ${modified_sqls} = 0 ]]; then
|
||||||
else
|
else
|
||||||
echo "Changes to the following files are not allowed:"
|
echo "Changes to the following files are not allowed:"
|
||||||
echo $(git diff --name-status ${sandbox_tag} \
|
echo $(git diff --name-status ${sandbox_tag} \
|
||||||
db/src/main/resources/sql/flyway | grep ^M | grep \.sql$)
|
db/src/main/resources/sql/flyway | grep "^M\|^D\|^R" | grep \.sql$)
|
||||||
|
echo "Make sure your branch is up to date with HEAD of master."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -15,7 +15,8 @@
|
||||||
# This file declares shell functions used by other scripts in this folder.
|
# This file declares shell functions used by other scripts in this folder.
|
||||||
|
|
||||||
# Fetch the tag of the currently deployed release of Nomulus server
|
# Fetch the tag of the currently deployed release of Nomulus server
|
||||||
# or SQL schema.
|
# or SQL schema. The caller is responsible for fetching relevant git
|
||||||
|
# tags to the local repo.
|
||||||
function fetchVersion() {
|
function fetchVersion() {
|
||||||
local deployed_system=${1}
|
local deployed_system=${1}
|
||||||
local env=${2}
|
local env=${2}
|
||||||
|
|
Loading…
Add table
Reference in a new issue