feat: add tenant and user management with migrations, handlers, and tests
- Implemented tenant and user management features including: - Tenant creation and management with associated migrations. - User creation and management with associated migrations. - Tenant membership management with associated migrations. - Platform user roles management with associated migrations. - Quota management with associated migrations. - Article and template management with associated migrations. - Added HTTP handlers for templates and workspaces. - Created tests for protected and public routes. - Introduced a script to check tenant scope in SQL queries. - Documented task plan for backend completion and frontend foundation.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
.PHONY: dev-init dev-api migrate-up migrate-down migrate-create sqlc-generate tenant-scope-guard lint test tidy seed
|
||||
|
||||
DB_URL ?= postgres://geo:geo_dev@localhost:5432/geo?sslmode=disable
|
||||
MIGRATE_CMD ?= go run -tags postgres github.com/golang-migrate/migrate/v4/cmd/migrate@v4.19.1
|
||||
|
||||
dev-init: ## Start infra, run migrations, seed data
|
||||
docker compose up -d
|
||||
@echo "Waiting for postgres..."
|
||||
@sleep 3
|
||||
$(MAKE) migrate-up
|
||||
$(MAKE) seed
|
||||
|
||||
dev-api: ## Run tenant-api server
|
||||
go run ./cmd/tenant-api
|
||||
|
||||
migrate-up: ## Run all pending migrations
|
||||
$(MIGRATE_CMD) -path migrations -database "$(DB_URL)" up
|
||||
|
||||
migrate-down: ## Rollback last migration
|
||||
$(MIGRATE_CMD) -path migrations -database "$(DB_URL)" down 1
|
||||
|
||||
migrate-create: ## Create new migration (usage: make migrate-create NAME=xxx)
|
||||
$(MIGRATE_CMD) create -ext sql -dir migrations -seq $(NAME)
|
||||
|
||||
sqlc-generate: ## Generate typed Go code from SQL queries
|
||||
cd internal/tenant/repository && sqlc generate
|
||||
|
||||
tenant-scope-guard: ## Ensure tenant-scoped SQL includes tenant_id filters
|
||||
bash scripts/check_tenant_scope.sh
|
||||
|
||||
seed: ## Insert development seed data
|
||||
go run ./cmd/dev-seed
|
||||
|
||||
lint: ## Run linter
|
||||
golangci-lint run ./...
|
||||
|
||||
test: ## Run all tests
|
||||
go test ./... -count=1
|
||||
|
||||
tidy: ## Tidy go modules
|
||||
go mod tidy
|
||||
Reference in New Issue
Block a user