diff --git a/Makefile b/Makefile index 3e18938d..0359fcd0 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,10 @@ -.PHONY: env install-deps up worker app init lint test +.PHONY: env install-deps up open-db revision migrate worker app init lint test + +ifeq ($(shell test -e '.env' && echo -n yes),yes) + include .env +endif + +args := $(wordlist 2, 100, $(MAKECMDGOALS)) ## Create .env file from .env.example env: @@ -16,6 +22,18 @@ up: (trap 'docker compose -f dev-docker-compose.yaml down' INT; \ docker compose -f dev-docker-compose.yaml up --build --force-recreate --remove-orphans) +## Open database with docker-compose +open-db: + docker exec -it desbordante-postgres psql -d $(POSTGRES_DB) -U $(POSTGRES_USER) + +## Create new revision file automatically +revision: + poetry run alembic -c app/settings/alembic.ini revision --autogenerate + +## Make migrations in database +migrate: + poetry run alembic -c app/settings/alembic.ini upgrade $(args) + ## Run celery worker in watch mode worker: . .venv/bin/activate && watchmedo auto-restart --directory=./ --pattern='*.py' --recursive -- celery -A app.worker worker --loglevel=info --concurrency=1 @@ -34,6 +52,7 @@ lint: poetry run ruff format --check ./tests/*.py ./app/*.py poetry run black --check ./tests/*.py ./app/*.py poetry run mypy --ignore-missing-imports ./app/*.py + ## Run all tests in project test: poetry run pytest --verbosity=2 --showlocals -log-level=DEBUG --cov=app --cov-report term