DC = docker compose

.PHONY: help build up down logs sh migrate makemigrations createadmin test lint fmt messages compile

help:
	@grep -E '^[a-zA-Z_-]+:.*?##' $(MAKEFILE_LIST) | awk 'BEGIN{FS=":.*?## "}{printf "%-18s %s\n", $$1, $$2}'

build: ## Constroi as imagens
	$(DC) build

up: ## Sobe a stack completa
	$(DC) up -d

down: ## Derruba a stack
	$(DC) down

logs: ## Logs do web
	$(DC) logs -f web

sh: ## Shell no container web
	$(DC) exec web bash

migrate: ## Migra schema public + schemas de tenant
	$(DC) exec web python manage.py migrate_schemas

makemigrations: ## Gera migrations
	$(DC) exec web python manage.py makemigrations

createadmin: ## Cria um platform admin
	$(DC) exec web python manage.py create_platform_admin

test: ## Roda a suite de testes
	$(DC) exec web pytest

lint: ## Lint (ruff)
	$(DC) exec web ruff check .

fmt: ## Formata (ruff)
	$(DC) exec web ruff format .

messages: ## Extrai strings de traducao
	$(DC) exec web python manage.py makemessages -a --no-location

compile: ## Compila catalogos .po
	$(DC) exec web python manage.py compilemessages
