Some checks failed
Deploy to Production / deploy (push) Failing after 8s
- Renamed MYSQL_ROOT_PASSWORD to DB_ROOT_PASSWORD and MYSQL_PASSWORD to DB_PASSWORD for consistent naming - Updated docker-compose.yml to map DB_* variables to MySQL container's expected MYSQL_* format - Removed redundant DATABASE_URL variable since individual DB_* variables are now used - Added default values for DB_USER, DB_NAME, DB_HOST, and DB_PORT in docker-compose.yml - Updated all documentation files to reference new standar
85 lines
2.4 KiB
Markdown
85 lines
2.4 KiB
Markdown
# Database Variables Unified ✅
|
|
|
|
## Summary
|
|
|
|
All database configuration variables have been standardized to use the `DB_*` prefix for consistency and simplicity.
|
|
|
|
## Quick Reference
|
|
|
|
### Old Variable Names (REMOVED)
|
|
- ❌ `MYSQL_ROOT_PASSWORD`
|
|
- ❌ `MYSQL_PASSWORD`
|
|
- ❌ `DATABASE_URL`
|
|
|
|
### New Variable Names (CURRENT)
|
|
- ✅ `DB_ROOT_PASSWORD` - MySQL root password
|
|
- ✅ `DB_PASSWORD` - Application database password
|
|
- ✅ `DB_USER` - Database username (default: `voxblog`)
|
|
- ✅ `DB_NAME` - Database name (default: `voxblog`)
|
|
- ✅ `DB_HOST` - Database host (default: `mysql` in docker, `localhost` otherwise)
|
|
- ✅ `DB_PORT` - Database port (default: `3306`)
|
|
|
|
## Files Updated
|
|
|
|
1. **`.env.example`** - Updated with unified variable names and defaults
|
|
2. **`docker-compose.yml`** - MySQL container and API service use `DB_*` variables
|
|
3. **`scripts/migrate-db-vars.sh`** - Migration helper script
|
|
4. **`docs/DB_VARIABLE_MIGRATION.md`** - Comprehensive migration guide
|
|
|
|
## Application Code (No Changes Needed)
|
|
|
|
The following files already used `DB_*` variables:
|
|
- ✅ `apps/api/src/db.ts`
|
|
- ✅ `apps/api/drizzle.config.ts`
|
|
- ✅ `apps/api/src/db/migrate.ts`
|
|
|
|
## Migration Instructions
|
|
|
|
### For Existing Users
|
|
|
|
Run the migration script:
|
|
```bash
|
|
./scripts/migrate-db-vars.sh
|
|
```
|
|
|
|
Or manually update your `.env`:
|
|
```bash
|
|
# Replace:
|
|
MYSQL_ROOT_PASSWORD=xxx → DB_ROOT_PASSWORD=xxx
|
|
MYSQL_PASSWORD=xxx → DB_PASSWORD=xxx
|
|
```
|
|
|
|
Then restart services:
|
|
```bash
|
|
docker-compose down && docker-compose up -d
|
|
```
|
|
|
|
### For New Users
|
|
|
|
Just copy and configure:
|
|
```bash
|
|
cp .env.example .env
|
|
# Edit .env with your passwords
|
|
docker-compose up -d
|
|
```
|
|
|
|
## Benefits
|
|
|
|
1. **Consistency** - Single naming convention across the entire project
|
|
2. **Simplicity** - Easier to remember and use
|
|
3. **Clarity** - Clear distinction between container and application config
|
|
4. **Flexibility** - Default values for easier local development
|
|
5. **Maintainability** - Less confusion, fewer errors
|
|
|
|
## Why This Change?
|
|
|
|
Previously, the project mixed two naming conventions:
|
|
- `MYSQL_*` for some variables (from MySQL Docker image convention)
|
|
- `DB_*` for application code
|
|
|
|
This created confusion about which variables to set and where. Now everything uses `DB_*`, and docker-compose handles the mapping to MySQL container's expected `MYSQL_*` environment variables internally.
|
|
|
|
## Need Help?
|
|
|
|
See the full migration guide: `docs/DB_VARIABLE_MIGRATION.md`
|