KERS_DB_BACKEND ?= mysql KERS_SQLITE_FILE ?= kers.sqlite3 # Discover virtualenv location PYTHON ?= $(shell find -mindepth 3 -maxdepth 3 -path "*/bin/python") ifeq ($(PYTHON),) $(error No virtualenv found) endif VENVBIN := $(dir $(PYTHON)) .PHONY: server celery beat server: $(PYTHON) manage.py runserver celery: $(VENVBIN)/celery -A KeRS worker -l info beat: $(VENVBIN)/celery -A KeRS beat -l info --scheduler django_celery_beat.schedulers:DatabaseScheduler .PHONY: migrations migrate migrations: $(PYTHON) manage.py makemigrations migrate: $(PYTHON) manage.py migrate .PHONY: reset_db rewrite_migrations reset_db: @case "$(KERS_DB_BACKEND)" in \ mysql) printf "Please drop your MySQL/MariaDB tables and press enter"; read; ;; \ sqlite3) echo 'rm -f "$(KERS_SQLITE_FILE)"'; rm -f "$(KERS_SQLITE_FILE)"; ;; \ esac make migrate rewrite_migrations: @printf "Only for when there is no data in production yet. Continue? (y/N) "; read continue; [ "$$continue" = y ] # Remove migrations but not users' migrations 0001 and 0002 rm -f events/migrations/0*_*.py users/migrations/000[3-9].py users/migrations/00[1-9]*.py make migrations make reset_db