This Rust CMS project uses Docker PostgreSQL as the primary database. This guide ensures you always connect to the correct database and prevents data loss.
ALWAYS USE THE DOCKER DATABASE - This contains all your data, settings, and typography configurations.
- Container:
rustcms_dev_postgres - Host:
localhost:5432 - Database:
my_rust_cms - User:
myrustcms - Password:
password
./setup-database.sh# 1. Ensure Docker is running
docker info
# 2. Start PostgreSQL container
docker-compose up -d postgres
# 3. Copy correct environment
cp .env.docker .env
# 4. Stop any conflicting local PostgreSQL
brew services stop postgresql@15
brew services stop postgresql@14# Use the development script (includes database setup)
./dev-start.sh# 1. Setup database first
./setup-database.sh
# 2. Start backend
cd backend
cargo runSolution: You're connecting to the wrong database
# Stop local PostgreSQL
brew services stop postgresql@15
# Run database setup
./setup-database.sh
# Restart backend
cd backend && cargo runSolution: Backend is connected to empty database
# Check Docker container is running
docker ps | grep rustcms_dev_postgres
# Verify data exists in Docker database
docker exec rustcms_dev_postgres psql -U myrustcms -d my_rust_cms -c "SELECT COUNT(*) FROM settings WHERE setting_type = 'typography';"
# Should return 29 typography settingsSolution: Stop local PostgreSQL services
# Stop all local PostgreSQL
brew services stop postgresql@14
brew services stop postgresql@15
# Check what's running on port 5432
lsof -i :5432
# Should only show Docker PostgreSQL- Purpose: Master configuration for Docker database
- Usage: Always copy this to
.envbefore development - Contains: Correct database credentials and settings
- Purpose: Active environment file used by backend
- Usage: Automatically created by setup scripts
- Note: Ignored by git, safe to modify locally
- Purpose: Old development configuration
- Problem: Points to local PostgreSQL (wrong database)
- Status: Deprecated, use
.env.dockerinstead
- Primary: Docker PostgreSQL container (
myrustcms_dev_postgres) - Contains: All settings, typography configurations, posts, users
- Backup: Regular Docker volume backups recommended
- ❌ Don't use
dev.env(points to wrong database) - ❌ Don't start local PostgreSQL services
- ❌ Don't create new databases manually
- ❌ Don't modify database credentials without updating all configs
- ✅ Always run
./setup-database.shbefore development - ✅ Use
./dev-start.shfor automated setup - ✅ Verify database connection before making changes
- ✅ Keep Docker container running during development
# Test connection to Docker database
docker exec myrustcms_dev_postgres psql -U myrustcms -d my_rust_cms -c "SELECT version();"# Count total settings
docker exec myrustcms_dev_postgres psql -U myrustcms -d my_rust_cms -c "SELECT setting_type, COUNT(*) FROM settings GROUP BY setting_type;"
# Should show:
# typography | 29
# theme | 5
# container | 30
# etc.# Test API endpoint
curl -s "http://localhost:8081/api/public/system/settings" | head -c 100
# Should return JSON with settings dataIf you encounter database issues:
- First: Run
./setup-database.sh - Second: Check this guide's troubleshooting section
- Third: Verify Docker container is running and accessible
- Last Resort: Check Docker logs:
docker-compose logs postgres
Remember: Always use the Docker database - it contains all your work!