Files
cannaiq/DATABASE-GUIDE.md
2025-11-28 19:45:44 -07:00

63 lines
1.7 KiB
Markdown

# Database Usage Guide
## ⚠️ CRITICAL: Which Database To Use
### Dutchie Database (PORT 54320) - **USE THIS FOR EVERYTHING**
```bash
DATABASE_URL="postgresql://dutchie:dutchie_local_pass@localhost:54320/dutchie_menus"
```
**Use for:**
- ✅ Running the backend application (`npm run dev`)
- ✅ Database migrations
- ✅ API development
- ✅ Frontend development
- ✅ All production features
- ✅ Testing the complete application
### Sail Database (PORT 5432) - **SCRAPER TESTING ONLY**
```bash
DATABASE_URL="postgresql://sail:password@localhost:5432/dutchie_menus"
```
**Use ONLY for:**
- ⚠️ Testing individual scrapers in isolation
- ⚠️ And ONLY when explicitly needed
## Default Rule
**When in doubt, use Dutchie (port 54320).**
## Quick Reference Commands
### Start Backend (Production)
```bash
cd /home/kelly/dutchie-menus/backend
DATABASE_URL="postgresql://dutchie:dutchie_local_pass@localhost:54320/dutchie_menus" npm run dev
```
### Run Migrations
```bash
cd /home/kelly/dutchie-menus/backend
DATABASE_URL="postgresql://dutchie:dutchie_local_pass@localhost:54320/dutchie_menus" npx tsx src/db/migrate.ts
```
### Database Console Access
```bash
# Dutchie (production)
PGPASSWORD=dutchie_local_pass psql -h localhost -p 54320 -U dutchie -d dutchie_menus
# Sail (scraper testing only)
PGPASSWORD=password psql -h localhost -p 5432 -U sail -d dutchie_menus
```
## Why Two Databases?
- **Dutchie**: Main application database, contains real data
- **Sail**: Isolated environment for testing scrapers without affecting production data
## Common Mistake
**Don't do this:** Using sail database for application features/migrations
**Do this:** Use dutchie database for all application work