From 1ea08c670fabbcb14127cabd679e0dbb9cabfd9d Mon Sep 17 00:00:00 2001 From: Eliseu Egewarth Date: Fri, 18 Aug 2017 07:46:00 -0300 Subject: [PATCH] Implementa script check_migrations (#1411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adiciona rotina de checagem de migração Signed-off-by: Eliseu Egewarth * Adiciona Campos sem gerar makemigrations Signed-off-by: Eliseu Egewarth * Move script check_migrations.sh para o estagio 'before_script' Signed-off-by: Eliseu Egewarth * Revert "Adiciona Campos sem gerar makemigrations" This reverts commit c61154ec862daa7540ef16741acf1e464fdb2797. * Adding color for check failures Signed-off-by: Eliseu Egewarth --- .travis.yml | 1 + check_migrations.sh | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 check_migrations.sh diff --git a/.travis.yml b/.travis.yml index 0e0a27ad4..eb6abe0c3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ before_script: - cp sapl/.env_test sapl/.env - psql -c "CREATE USER sapl WITH PASSWORD 'sapl'" -U postgres; - psql -c "CREATE DATABASE sapl OWNER sapl;" -U postgres + - ./check_migrations.sh script: - ./manage.py migrate diff --git a/check_migrations.sh b/check_migrations.sh new file mode 100755 index 000000000..31f042207 --- /dev/null +++ b/check_migrations.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +python manage.py makemigrations --dry-run --exit + +MIGRATIONS=$? + +NC='\033[0m' + +if [ $MIGRATIONS -eq 0 ]; then + RED='\033[0;31m' + echo -e "${RED}You have unapplied code changes. run 'python manage.py makemigrations' before submitting your code...${NC}" + exit 1 +else + GREEN='\033[0;32m' + echo -e "Working normally..." + exit 0 +fi \ No newline at end of file