data seed feature for demo and prod
This commit is contained in:
347
Makefile
347
Makefile
@@ -1,7 +1,16 @@
|
||||
# Multitenant ecommerce application Makefile (Windows Compatible)
|
||||
# Wizamart Multi-Tenant E-Commerce Platform Makefile
|
||||
# Cross-platform compatible (Windows & Linux)
|
||||
|
||||
.PHONY: install install-dev install-docs install-all dev test test-coverage lint format check docker-build docker-up docker-down clean help
|
||||
|
||||
# Detect if we're in a virtual environment and set Python path accordingly
|
||||
# Detect OS
|
||||
ifeq ($(OS),Windows_NT)
|
||||
DETECTED_OS := Windows
|
||||
else
|
||||
DETECTED_OS := $(shell uname -s)
|
||||
endif
|
||||
|
||||
# Set Python based on OS
|
||||
PYTHON := python
|
||||
PIP := pip
|
||||
|
||||
@@ -23,9 +32,9 @@ install-docs:
|
||||
|
||||
install-all: install install-dev install-test install-docs
|
||||
|
||||
setup: install-all migrate-up
|
||||
@echo Development environment setup complete!
|
||||
@echo Run 'make dev' to start development server
|
||||
setup: install-all migrate-up init-prod
|
||||
@echo "✅ Development environment setup complete!"
|
||||
@echo "Run 'make dev' to start development server"
|
||||
|
||||
# =============================================================================
|
||||
# DEVELOPMENT SERVERS
|
||||
@@ -34,78 +43,96 @@ setup: install-all migrate-up
|
||||
dev:
|
||||
$(PYTHON) -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
||||
|
||||
dev-with-docs:
|
||||
@echo Starting API and documentation servers...
|
||||
@start /B $(PYTHON) -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
|
||||
@timeout /t 3 >nul
|
||||
@$(PYTHON) -m mkdocs serve --dev-addr=0.0.0.0:8001
|
||||
|
||||
dev-full: dev-with-docs
|
||||
@echo Development environment ready!
|
||||
@echo API server: http://localhost:8000
|
||||
@echo API docs: http://localhost:8000/docs
|
||||
@echo Documentation: http://localhost:8001
|
||||
|
||||
# =============================================================================
|
||||
# DATABASE MIGRATIONS
|
||||
# =============================================================================
|
||||
|
||||
migrate-create:
|
||||
@if [ "$(message)" = "" ]; then \
|
||||
ifeq ($(DETECTED_OS),Windows)
|
||||
@if "$(message)"=="" (echo Error: Please provide a message. Usage: make migrate-create message="your_description") else ($(PYTHON) -m alembic revision --autogenerate -m "$(message)")
|
||||
else
|
||||
@if [ -z "$(message)" ]; then \
|
||||
echo "Error: Please provide a message. Usage: make migrate-create message=\"your_description\""; \
|
||||
else \
|
||||
$(PYTHON) -m alembic revision --autogenerate -m "$(message)"; \
|
||||
fi
|
||||
endif
|
||||
|
||||
migrate-create-manual:
|
||||
ifeq ($(DETECTED_OS),Windows)
|
||||
@if "$(message)"=="" (echo Error: Please provide a message. Usage: make migrate-create-manual message="your_description") else ($(PYTHON) -m alembic revision -m "$(message)")
|
||||
else
|
||||
@if [ -z "$(message)" ]; then \
|
||||
echo "Error: Please provide a message. Usage: make migrate-create-manual message=\"your_description\""; \
|
||||
else \
|
||||
$(PYTHON) -m alembic revision -m "$(message)"; \
|
||||
fi
|
||||
endif
|
||||
|
||||
migrate-up:
|
||||
@echo Running database migrations...
|
||||
@echo "Running database migrations..."
|
||||
$(PYTHON) -m alembic upgrade head
|
||||
@echo Migrations completed successfully
|
||||
@echo "✅ Migrations completed successfully"
|
||||
|
||||
migrate-down:
|
||||
@echo Rolling back last migration...
|
||||
@echo "Rolling back last migration..."
|
||||
$(PYTHON) -m alembic downgrade -1
|
||||
@echo Rollback completed
|
||||
@echo "✅ Rollback completed"
|
||||
|
||||
migrate-status:
|
||||
@echo Current migration status:
|
||||
@echo "Current migration status:"
|
||||
$(PYTHON) -m alembic current
|
||||
@echo.
|
||||
@echo Migration history:
|
||||
@echo ""
|
||||
@echo "Migration history:"
|
||||
$(PYTHON) -m alembic history --verbose
|
||||
|
||||
# =============================================================================
|
||||
# DATABASE INITIALIZATION & SEEDING
|
||||
# =============================================================================
|
||||
|
||||
init-prod:
|
||||
@echo "🔧 Initializing production database..."
|
||||
$(PYTHON) scripts/init_production.py
|
||||
@echo "✅ Production initialization completed"
|
||||
|
||||
# Demo data seeding - Cross-platform using Python to set environment
|
||||
seed-demo:
|
||||
@echo "🎪 Seeding demo data (normal mode)..."
|
||||
ifeq ($(DETECTED_OS),Windows)
|
||||
@set SEED_MODE=normal&& $(PYTHON) scripts/seed_demo.py
|
||||
else
|
||||
SEED_MODE=normal $(PYTHON) scripts/seed_demo.py
|
||||
endif
|
||||
@echo "✅ Demo seeding completed"
|
||||
|
||||
seed-demo-minimal:
|
||||
@echo "🎪 Seeding demo data (minimal mode - 1 vendor only)..."
|
||||
ifeq ($(DETECTED_OS),Windows)
|
||||
@set SEED_MODE=minimal&& $(PYTHON) scripts/seed_demo.py
|
||||
else
|
||||
SEED_MODE=minimal $(PYTHON) scripts/seed_demo.py
|
||||
endif
|
||||
@echo "✅ Minimal demo seeding completed"
|
||||
|
||||
seed-demo-reset:
|
||||
@echo "⚠️ WARNING: This will DELETE ALL existing data!"
|
||||
ifeq ($(DETECTED_OS),Windows)
|
||||
@set SEED_MODE=reset&& $(PYTHON) scripts/seed_demo.py
|
||||
else
|
||||
SEED_MODE=reset $(PYTHON) scripts/seed_demo.py
|
||||
endif
|
||||
|
||||
db-setup: migrate-up init-prod seed-demo
|
||||
@echo "✅ Database setup complete!"
|
||||
@echo "Run 'make dev' to start development server"
|
||||
|
||||
db-reset: migrate-down migrate-up seed-demo-reset
|
||||
@echo "✅ Database completely reset!"
|
||||
|
||||
backup-db:
|
||||
@echo Creating database backup...
|
||||
@echo "Creating database backup..."
|
||||
@$(PYTHON) scripts/backup_database.py
|
||||
|
||||
# Add these commands to the DATABASE section after backup-db:
|
||||
|
||||
seed:
|
||||
@echo Seeding database with comprehensive test data...
|
||||
$(PYTHON) scripts/seed_database.py
|
||||
@echo Seeding completed successfully
|
||||
|
||||
seed-minimal:
|
||||
@echo Seeding database with minimal data (admin + 1 vendor)...
|
||||
$(PYTHON) scripts/seed_database.py --minimal
|
||||
@echo Minimal seeding completed
|
||||
|
||||
seed-reset:
|
||||
@echo WARNING: This will DELETE ALL existing data!
|
||||
$(PYTHON) scripts/seed_database.py --reset
|
||||
@echo Database reset and seeded
|
||||
|
||||
# Complete database setup (migrate + seed)
|
||||
db-setup: migrate-up seed
|
||||
@echo Database setup complete!
|
||||
@echo Run 'make dev' to start development server
|
||||
|
||||
db-reset: migrate-down migrate-up seed-reset
|
||||
@echo Database completely reset!
|
||||
|
||||
# =============================================================================
|
||||
# TESTING
|
||||
# =============================================================================
|
||||
@@ -142,54 +169,54 @@ test-inventory:
|
||||
# =============================================================================
|
||||
|
||||
format:
|
||||
@echo Running black...
|
||||
@echo "Running black..."
|
||||
$(PYTHON) -m black . --exclude venv
|
||||
@echo Running isort...
|
||||
@echo "Running isort..."
|
||||
$(PYTHON) -m isort . --skip venv
|
||||
|
||||
lint:
|
||||
@echo Running linting...
|
||||
@echo "Running linting..."
|
||||
$(PYTHON) -m ruff check . --exclude venv
|
||||
$(PYTHON) -m mypy . --ignore-missing-imports --exclude venv
|
||||
|
||||
# Alternative lint if still using flake8
|
||||
lint-flake8:
|
||||
@echo Running linting...
|
||||
@echo "Running linting..."
|
||||
$(PYTHON) -m flake8 . --max-line-length=120 --extend-ignore=E203,W503,I201,I100 --exclude=venv,__pycache__,.git
|
||||
$(PYTHON) -m mypy . --ignore-missing-imports --exclude venv
|
||||
|
||||
# Combined format and lint
|
||||
check: format lint
|
||||
|
||||
# Combined test with coverage and linting
|
||||
ci: format lint test-coverage
|
||||
|
||||
# Quality assurance workflow
|
||||
qa: format lint test-coverage docs-check
|
||||
@echo Quality assurance checks completed!
|
||||
@echo "Quality assurance checks completed!"
|
||||
|
||||
# =============================================================================
|
||||
# DOCUMENTATION
|
||||
# =============================================================================
|
||||
|
||||
docs-serve:
|
||||
@echo Starting documentation server...
|
||||
@echo "Starting documentation server..."
|
||||
$(PYTHON) -m mkdocs serve --dev-addr=0.0.0.0:8001
|
||||
|
||||
docs-build:
|
||||
@echo Building documentation...
|
||||
@echo "Building documentation..."
|
||||
$(PYTHON) -m mkdocs build --clean --strict
|
||||
|
||||
docs-deploy:
|
||||
@echo Deploying documentation...
|
||||
@echo "Deploying documentation..."
|
||||
$(PYTHON) -m mkdocs gh-deploy --clean
|
||||
|
||||
docs-clean:
|
||||
ifeq ($(DETECTED_OS),Windows)
|
||||
@if exist site rmdir /s /q site
|
||||
@echo Documentation build files cleaned!
|
||||
else
|
||||
@rm -rf site
|
||||
endif
|
||||
@echo "Documentation build files cleaned!"
|
||||
|
||||
docs-check:
|
||||
@echo Checking documentation for issues...
|
||||
@echo "Checking documentation for issues..."
|
||||
$(PYTHON) -m mkdocs build --strict --verbose
|
||||
|
||||
# =============================================================================
|
||||
@@ -222,30 +249,43 @@ deploy-prod: migrate-up
|
||||
# =============================================================================
|
||||
|
||||
clean:
|
||||
ifeq ($(DETECTED_OS),Windows)
|
||||
@if exist htmlcov rmdir /s /q htmlcov
|
||||
@if exist .pytest_cache rmdir /s /q .pytest_cache
|
||||
@if exist .coverage del .coverage
|
||||
@if exist .mypy_cache rmdir /s /q .mypy_cache
|
||||
@for /d /r . %%d in (__pycache__) do @if exist "%%d" rmdir /s /q "%%d"
|
||||
@del /s /q *.pyc 2>nul || echo No .pyc files found
|
||||
else
|
||||
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
|
||||
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
|
||||
@rm -rf htmlcov .pytest_cache .coverage .mypy_cache 2>/dev/null || true
|
||||
endif
|
||||
@echo "Cleaned up build artifacts"
|
||||
|
||||
verify-setup:
|
||||
@echo Running setup verification...
|
||||
@echo "Running setup verification..."
|
||||
@$(PYTHON) scripts/verify_setup.py
|
||||
|
||||
# Check Python and virtual environment
|
||||
check-env:
|
||||
@echo Checking Python environment...
|
||||
@echo Python version:
|
||||
@echo "Checking Python environment..."
|
||||
@echo "Detected OS: $(DETECTED_OS)"
|
||||
@echo ""
|
||||
@echo "Python version:"
|
||||
@$(PYTHON) --version
|
||||
@echo.
|
||||
@echo Python location:
|
||||
@echo ""
|
||||
ifeq ($(DETECTED_OS),Windows)
|
||||
@echo "Python location:"
|
||||
@where $(PYTHON)
|
||||
@echo.
|
||||
@echo Virtual environment active:
|
||||
else
|
||||
@echo "Python location:"
|
||||
@which $(PYTHON)
|
||||
endif
|
||||
@echo ""
|
||||
@echo "Virtual environment active:"
|
||||
@$(PYTHON) -c "import sys; print('YES' if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix) else 'NO')"
|
||||
@echo.
|
||||
@echo Python executable:
|
||||
@echo ""
|
||||
@echo "Python executable:"
|
||||
@$(PYTHON) -c "import sys; print(sys.executable)"
|
||||
|
||||
# =============================================================================
|
||||
@@ -253,75 +293,92 @@ check-env:
|
||||
# =============================================================================
|
||||
|
||||
help:
|
||||
@echo LetzShop API Development Commands
|
||||
@echo.
|
||||
@echo === SETUP ===
|
||||
@echo install - Install production dependencies
|
||||
@echo install-test - Install test dependencies only
|
||||
@echo install-dev - Install development dependencies
|
||||
@echo install-all - Install all dependencies
|
||||
@echo setup - Complete development setup
|
||||
@echo.
|
||||
@echo === DEVELOPMENT ===
|
||||
@echo dev - Start API development server
|
||||
@echo dev-full - Start API and documentation servers
|
||||
@echo.
|
||||
@echo === DATABASE ===
|
||||
@echo migrate-create message="msg" - Create new migration
|
||||
@echo migrate-up - Apply pending migrations
|
||||
@echo migrate-down - Rollback last migration
|
||||
@echo migrate-status - Show migration status
|
||||
@echo backup-db - Backup database
|
||||
@echo.
|
||||
@echo === TESTING ===
|
||||
@echo test - Run all tests
|
||||
@echo test-coverage - Run tests with coverage
|
||||
@echo test-fast - Run fast tests only
|
||||
@echo.
|
||||
@echo === CODE QUALITY ===
|
||||
@echo format - Format code (black + isort)
|
||||
@echo lint - Run linting (ruff + mypy)
|
||||
@echo lint-flake8 - Run linting (flake8 + mypy - alternative)
|
||||
@echo check - Format + lint
|
||||
@echo ci - Full CI pipeline
|
||||
@echo qa - Quality assurance (format, lint, test, docs check)
|
||||
@echo.
|
||||
@echo === DOCUMENTATION ===
|
||||
@echo docs-serve - Start documentation server
|
||||
@echo docs-build - Build documentation
|
||||
@echo.
|
||||
@echo === DOCKER ===
|
||||
@echo docker-build - Build Docker containers
|
||||
@echo docker-up - Start Docker containers
|
||||
@echo docker-down - Stop Docker containers
|
||||
@echo docker-restart - Restart Docker containers
|
||||
@echo.
|
||||
@echo === DEPLOYMENT ===
|
||||
@echo deploy-staging - Deploy to staging environment
|
||||
@echo deploy-prod - Deploy to production environment
|
||||
@echo.
|
||||
@echo === UTILITIES ===
|
||||
@echo clean - Clean build artifacts
|
||||
@echo verify-setup - Verify project setup
|
||||
@echo check-env - Check Python and virtual environment
|
||||
@echo.
|
||||
@echo === DAILY WORKFLOW ===
|
||||
@echo make dev # Start development
|
||||
@echo make migrate-create message="feature" # Create migration
|
||||
@echo make migrate-up # Apply migration
|
||||
@echo make test # Run tests
|
||||
@echo "Wizamart Platform Development Commands"
|
||||
@echo ""
|
||||
@echo "=== SETUP ==="
|
||||
@echo " install - Install production dependencies"
|
||||
@echo " install-test - Install test dependencies only"
|
||||
@echo " install-dev - Install development dependencies"
|
||||
@echo " install-all - Install all dependencies"
|
||||
@echo " setup - Complete development setup"
|
||||
@echo ""
|
||||
@echo "=== DEVELOPMENT ==="
|
||||
@echo " dev - Start API development server"
|
||||
@echo ""
|
||||
@echo "=== DATABASE ==="
|
||||
@echo " migrate-create message=\"msg\" - Create new migration"
|
||||
@echo " migrate-up - Apply pending migrations"
|
||||
@echo " migrate-down - Rollback last migration"
|
||||
@echo " migrate-status - Show migration status"
|
||||
@echo " init-prod - Initialize production essentials"
|
||||
@echo " seed-demo - Seed demo data (3 vendors)"
|
||||
@echo " seed-demo-minimal - Seed minimal demo (1 vendor)"
|
||||
@echo " seed-demo-reset - DELETE ALL and reseed"
|
||||
@echo " db-setup - Full dev setup (migrate + init + seed)"
|
||||
@echo " backup-db - Backup database"
|
||||
@echo ""
|
||||
@echo "=== TESTING ==="
|
||||
@echo " test - Run all tests"
|
||||
@echo " test-coverage - Run tests with coverage"
|
||||
@echo " test-fast - Run fast tests only"
|
||||
@echo ""
|
||||
@echo "=== CODE QUALITY ==="
|
||||
@echo " format - Format code (black + isort)"
|
||||
@echo " lint - Run linting (ruff + mypy)"
|
||||
@echo " check - Format + lint"
|
||||
@echo " ci - Full CI pipeline"
|
||||
@echo " qa - Quality assurance"
|
||||
@echo ""
|
||||
@echo "=== DOCUMENTATION ==="
|
||||
@echo " docs-serve - Start documentation server"
|
||||
@echo " docs-build - Build documentation"
|
||||
@echo ""
|
||||
@echo "=== DOCKER ==="
|
||||
@echo " docker-build - Build Docker containers"
|
||||
@echo " docker-up - Start Docker containers"
|
||||
@echo " docker-down - Stop Docker containers"
|
||||
@echo ""
|
||||
@echo "=== UTILITIES ==="
|
||||
@echo " clean - Clean build artifacts"
|
||||
@echo " check-env - Check Python environment and OS"
|
||||
@echo ""
|
||||
@echo "=== DAILY WORKFLOW ==="
|
||||
@echo " make setup # Initial setup"
|
||||
@echo " make dev # Start development"
|
||||
@echo " make migrate-create message=\"feature\" # Create migration"
|
||||
@echo " make migrate-up # Apply migration"
|
||||
@echo " make test # Run tests"
|
||||
|
||||
help-db:
|
||||
@echo === DATABASE COMMANDS ===
|
||||
@echo migrate-create message="description" - Create auto-generated migration
|
||||
@echo migrate-create-manual message="desc" - Create empty migration template
|
||||
@echo migrate-up - Apply all pending migrations
|
||||
@echo migrate-down - Rollback last migration
|
||||
@echo migrate-status - Show current status and history
|
||||
@echo backup-db - Create database backup
|
||||
@echo.
|
||||
@echo TYPICAL WORKFLOW:
|
||||
@echo 1. Edit your SQLAlchemy models
|
||||
@echo 2. make migrate-create message="add_new_feature"
|
||||
@echo 3. Review the generated migration file
|
||||
@echo 4. make migrate-up
|
||||
@echo "=== DATABASE COMMANDS ==="
|
||||
@echo ""
|
||||
@echo "MIGRATIONS:"
|
||||
@echo " migrate-create message=\"description\" - Create auto-generated migration"
|
||||
@echo " migrate-create-manual message=\"desc\" - Create empty migration template"
|
||||
@echo " migrate-up - Apply all pending migrations"
|
||||
@echo " migrate-down - Rollback last migration"
|
||||
@echo " migrate-status - Show current status and history"
|
||||
@echo ""
|
||||
@echo "INITIALIZATION:"
|
||||
@echo " init-prod - Create admin user + settings (SAFE for production)"
|
||||
@echo ""
|
||||
@echo "DEMO DATA (Development only):"
|
||||
@echo " seed-demo - Create 3 demo vendors with data"
|
||||
@echo " seed-demo-minimal - Create 1 demo vendor only"
|
||||
@echo " seed-demo-reset - DELETE ALL data and reseed (DANGEROUS!)"
|
||||
@echo ""
|
||||
@echo "WORKFLOWS:"
|
||||
@echo " db-setup - Complete dev setup (migrate + init + seed)"
|
||||
@echo " db-reset - Nuclear option: rollback + reset + reseed"
|
||||
@echo ""
|
||||
@echo "TYPICAL FIRST-TIME SETUP:"
|
||||
@echo " 1. make migrate-up # Apply migrations"
|
||||
@echo " 2. make init-prod # Create admin user"
|
||||
@echo " 3. make seed-demo # Add demo data"
|
||||
@echo " 4. make dev # Start developing"
|
||||
@echo ""
|
||||
@echo "PRODUCTION SETUP:"
|
||||
@echo " 1. Set ENV=production or ENVIRONMENT=production"
|
||||
@echo " 2. make migrate-up"
|
||||
@echo " 3. make init-prod (with secure credentials in .env)"
|
||||
@echo " 4. Create vendors via admin panel"
|
||||
Reference in New Issue
Block a user