chore: PostgreSQL migration compatibility and infrastructure improvements
Database & Migrations: - Update all Alembic migrations for PostgreSQL compatibility - Remove SQLite-specific syntax (AUTOINCREMENT, etc.) - Add database utility helpers for PostgreSQL operations - Fix services to use PostgreSQL-compatible queries Documentation: - Add comprehensive Docker deployment guide - Add production deployment documentation - Add infrastructure architecture documentation - Update database setup guide for PostgreSQL-only - Expand troubleshooting guide Architecture & Validation: - Add migration.yaml rules for SQL compatibility checking - Enhance validate_architecture.py with migration validation - Update architecture rules to validate Alembic migrations Development: - Fix duplicate install-all target in Makefile - Add Celery/Redis validation to install.py script - Add docker-compose.test.yml for CI testing - Add squash_migrations.py utility script - Update tests for PostgreSQL compatibility - Improve test fixtures in conftest.py Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,19 +12,29 @@ After cloning the repository, follow these steps to get your database ready:
|
||||
make install-all
|
||||
```
|
||||
|
||||
### 2. Set Up Environment
|
||||
### 2. Start PostgreSQL Database
|
||||
```bash
|
||||
# Start the development database with Docker
|
||||
make docker-up
|
||||
|
||||
# Or manually:
|
||||
docker-compose up -d db
|
||||
```
|
||||
|
||||
### 3. Set Up Environment
|
||||
```bash
|
||||
# Copy the example environment file
|
||||
cp .env.example .env
|
||||
|
||||
# Edit .env with your database configuration
|
||||
# For development, you can use SQLite:
|
||||
DATABASE_URL=sqlite:///./wizamart.db
|
||||
|
||||
# For PostgreSQL (recommended for production-like development):
|
||||
# DATABASE_URL=postgresql://username:password@localhost:5432/ecommerce_dev
|
||||
# The default works with docker-compose:
|
||||
DATABASE_URL=postgresql://wizamart_user:secure_password@localhost:5432/wizamart_db
|
||||
```
|
||||
|
||||
!!! note "PostgreSQL Required"
|
||||
This project requires PostgreSQL. SQLite is not supported.
|
||||
Docker Compose provides the easiest way to run PostgreSQL locally.
|
||||
|
||||
### 3. Run Database Migrations
|
||||
```bash
|
||||
# Apply all migrations to create the database schema
|
||||
@@ -136,27 +146,26 @@ make migrate-up
|
||||
|
||||
## Environment-Specific Setup
|
||||
|
||||
### Development (SQLite)
|
||||
### Development (Docker - Recommended)
|
||||
```env
|
||||
DATABASE_URL=sqlite:///./wizamart.db
|
||||
DATABASE_URL=postgresql://wizamart_user:secure_password@localhost:5432/wizamart_db
|
||||
```
|
||||
- Quick setup, no additional software needed
|
||||
- File-based database, easy to backup/restore
|
||||
- Good for local development and testing
|
||||
- Start with `make docker-up`
|
||||
- Consistent environment matching production
|
||||
- Easy to reset with `make db-reset`
|
||||
|
||||
### Development (PostgreSQL)
|
||||
### Development (Local PostgreSQL)
|
||||
```env
|
||||
DATABASE_URL=postgresql://user:password@localhost:5432/wizamart_dev
|
||||
```
|
||||
- More production-like environment
|
||||
- Better for testing complex queries
|
||||
- Required for certain advanced features
|
||||
- Use if you prefer a local PostgreSQL installation
|
||||
- Ensure PostgreSQL 15+ is installed
|
||||
|
||||
### Production
|
||||
```env
|
||||
DATABASE_URL=postgresql://user:password@production-host:5432/wizamart_prod
|
||||
```
|
||||
- Always use PostgreSQL in production
|
||||
- PostgreSQL is required for production
|
||||
- Migrations are applied automatically during deployment
|
||||
|
||||
## Troubleshooting
|
||||
@@ -312,19 +321,19 @@ python scripts/create_test_data.py
|
||||
To start completely fresh:
|
||||
|
||||
```bash
|
||||
# 1. Backup first (optional but recommended)
|
||||
cp wizamart.db wizamart.db.backup
|
||||
# Complete reset (drops all data and recreates)
|
||||
make db-reset
|
||||
|
||||
# 2. Delete database
|
||||
rm wizamart.db
|
||||
# Or step by step:
|
||||
# 1. Rollback all migrations
|
||||
make migrate-down # Run multiple times or use: alembic downgrade base
|
||||
|
||||
# 3. Recreate schema
|
||||
# 2. Recreate schema
|
||||
make migrate-up
|
||||
|
||||
# 4. Seed all data
|
||||
python scripts/create_test_data.py
|
||||
python scripts/create_inventory.py
|
||||
python scripts/create_landing_page.py
|
||||
# 3. Seed data
|
||||
make init-prod
|
||||
make seed-demo
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
Reference in New Issue
Block a user