Skip to content

Commit 828cfb8

Browse files
committed
Added a switch to bin/mkrelease to permit mixed data and schema migrations (applicable when the data migrations are as tiny and swift as schema migrations, such as when adding a new entry to a name model).
- Legacy-Id: 13215
1 parent 128be4b commit 828cfb8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

bin/mkrelease

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ MSG=""
8787
PROJ=ietfdb
8888
VERFILE=ietf/__init__.py
8989
SETTINGS=ietf/settings.py
90+
PERMIT_MIGR_MIX=""
9091
do=""
9192

9293
if [ "$(uname)" = "Linux" ]; then
@@ -107,6 +108,7 @@ while true ; do
107108
-h| --help) usage; exit;; # Show this help, then exit
108109
-m| --message) MSG=$2; shift;; # Specify a commit message
109110
-n| --dry-run) do="echo ==>";; # Show what would be done
111+
-p| --permit-migr-mix) PERMIT_MIGR_MIX=1;; # Permit mixed schema and data migrations
110112
-v| --verbose) VERBOSE=1;; # Be more talkative
111113
-V| --version) version; exit;; # Show program version, then exit
112114
--) shift; break;;
@@ -179,10 +181,18 @@ changes=$( sed -n "/^$PROJ ($VER.*)/,/^ -- /p" changelog )
179181
note "Checking that we don't have both schema and data migrations ..."
180182
cur=$(svn info | awk '/^Revision:/ { print $2 }')
181183
migrations=$(svn log $PWD -v -r HEAD:$((cur-100)) | sed -n -e '1,/^Set version info and settings back to development mode/p' | grep '^...A /.*/migrations/0.*.py' | cut -c6- | awk '{ print $1 }' | sed -re 's|/trunk/||')
182-
if [ -n "$migrations" ]; then
184+
if [ -n "$migrations" -a -z "$PERMIT_MIGR_MIX" ]; then
183185
datamigr=$(for m in "$migrations"; do egrep -sl 'migrations\.RunPython' $m; done || true)
184186
schemamigr=$(for m in "$migrations"; do egrep -sl 'migrations\.(Add|Alter|Create|Delete|Remove|Rename)(Field|Model|UniqueTogether)' $m; done || true)
185187
if [ -n "$datamigr" -a -n "$schemamigr" ]; then
188+
echo -e "\n Schema migrations:"
189+
for m in $schemamigr; do
190+
echo " $m"
191+
done
192+
echo -e "\n Data migrations:"
193+
for m in $datamigr; do
194+
echo " $m"
195+
done
186196
die "\n Found both data migrations and schema migrations in this release.\n This is likely to cause delay between schema changes and deployment,\n which means the old code will run on the new schema longer than necessary."
187197
fi
188198
fi

0 commit comments

Comments
 (0)