mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-29 02:53:52 +00:00 
			
		
		
		
	/bin/sh and /usr/bin/env are the only two binaries that NixOS provides at a fixed path (outside a buildFHSUserEnv sandbox). This discussion was split from #11004. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
		
			
				
	
	
		
			36 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/env bash
 | |
| set -e
 | |
| echo 'Testing whether migrations are consistent with models'
 | |
| 
 | |
| # 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]' \
 | |
|            -e ' 0052_auto_fix_realmalias_realm_nullable' \
 | |
|            -e ' 0003_auto_20150817_1733' \
 | |
|            -e ' 0002_auto_20150110_0810' \
 | |
|     | sed 's/\[[x ]\] /  /' \
 | |
|  || true)
 | |
| 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
 | |
|     echo "$new_auto_named_migrations"
 | |
|     echo
 | |
|     echo 'See https://zulip.readthedocs.io/en/latest/subsystems/schema-migrations.html for advice.'
 | |
|     echo
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| if ! ./manage.py makemigrations --check --dry-run; then
 | |
|     echo
 | |
|     # shellcheck disable=SC2016
 | |
|     echo 'ERROR: Migrations are not consistent with models!  Fix with `./tools/renumber-migrations`.'
 | |
|     echo 'See https://zulip.readthedocs.io/en/latest/subsystems/schema-migrations.html for details.'
 | |
|     echo
 | |
|     exit 1
 | |
| fi
 | |
| 
 | |
| echo "Success!  Migrations are consistent with models."
 |