2018-12-18 02:08:53 +01:00
|
|
|
#!/usr/bin/env bash
|
2016-01-10 05:15:19 +01:00
|
|
|
set -e
|
|
|
|
echo 'Testing whether migrations are consistent with models'
|
2017-07-10 22:54:01 +02:00
|
|
|
|
2018-02-10 03:43:26 +01:00
|
|
|
# Check if any migration looks to have a meaningless 'auto' name,
|
|
|
|
# other than the existing handful from 2016 and 2017.
|
|
|
|
new_auto_named_migrations=$(./manage.py showmigrations \
|
|
|
|
| grep -E ' [0-9]{4}_auto_' \
|
|
|
|
| grep -Eve ' [0-9]{4}_auto_201[67]' \
|
2018-05-03 21:23:25 +02:00
|
|
|
-e ' 0052_auto_fix_realmalias_realm_nullable' \
|
|
|
|
-e ' 0003_auto_20150817_1733' \
|
|
|
|
-e ' 0002_auto_20150110_0810' \
|
2019-07-04 14:48:01 +02:00
|
|
|
-e ' 0002_auto_20190420_0723' \
|
2018-08-03 02:14:51 +02:00
|
|
|
| sed 's/\[[x ]\] / /' \
|
2018-02-10 03:43:26 +01:00
|
|
|
|| true)
|
2017-07-10 22:54:01 +02:00
|
|
|
if [ "$new_auto_named_migrations" != "" ]; then
|
|
|
|
echo "ERROR: New migrations with unclear automatically generated names."
|
|
|
|
echo "Please rename these migrations to have readable names:"
|
|
|
|
echo
|
2018-08-03 02:14:51 +02:00
|
|
|
echo "$new_auto_named_migrations"
|
2017-07-10 22:54:01 +02:00
|
|
|
echo
|
2017-11-16 19:51:44 +01:00
|
|
|
echo 'See https://zulip.readthedocs.io/en/latest/subsystems/schema-migrations.html for advice.'
|
2017-07-10 22:54:01 +02:00
|
|
|
echo
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-02-11 01:40:55 +01:00
|
|
|
if ! ./manage.py makemigrations --check --dry-run; then
|
2016-01-10 05:15:19 +01:00
|
|
|
echo
|
2018-08-03 02:14:51 +02:00
|
|
|
# shellcheck disable=SC2016
|
2017-04-05 11:49:21 +02:00
|
|
|
echo 'ERROR: Migrations are not consistent with models! Fix with `./tools/renumber-migrations`.'
|
2017-11-16 19:51:44 +01:00
|
|
|
echo 'See https://zulip.readthedocs.io/en/latest/subsystems/schema-migrations.html for details.'
|
2016-01-10 05:15:19 +01:00
|
|
|
echo
|
2016-06-15 18:19:54 +02:00
|
|
|
exit 1
|
2016-01-10 05:15:19 +01:00
|
|
|
fi
|
2018-02-10 03:43:26 +01:00
|
|
|
|
|
|
|
echo "Success! Migrations are consistent with models."
|