diff --git a/PROJECT_GUIDELINES.md b/PROJECT_GUIDELINES.md index bcc6aa2..5c9d6ae 100644 --- a/PROJECT_GUIDELINES.md +++ b/PROJECT_GUIDELINES.md @@ -89,6 +89,7 @@ VERIFY → Compile successfully ### When Working on Full-Stack Tasks - Backend changes are allowed when explicitly part of the task - Still follow all database protocols (atomic changes, validation, etc.) +- **If modifying database schema:** Update local database after schema.sql changes (see Database Operations section) - Still use Podman for all builds - Still include Bruno tests for API changes @@ -99,7 +100,15 @@ VERIFY → Compile successfully ### Database Operations (Full-Stack Tasks Only) - ✅ Follow **pgx v5 standards** for all database operations - ✅ Treat schema changes as **ATOMIC** - complete success or complete rejection -- ✅ When schema changes occur: delete database and rebuild with clean Podman cache +- ✅ **⚠️ CRITICAL: This is a pre-production application (NO production deployments exist)** + - When `database/schema/schema.sql` is updated, local databases must be updated + - **Option 1 (Recommended):** Recreate database with fresh schema: + ```bash + podman compose down -v # Delete volumes (WARNING: loses all data) + podman compose up -d # Start fresh with new schema + ``` + - **Option 2:** Manually apply schema changes to existing database using psql + - **DO NOT create migration files** - no legacy schema support needed - ✅ Use **pre-change checklist**: read schema → identify columns → plan changes → verify → read back - ✅ **Post-change validation**: ensure schema.sql, models.go, and queries.sql are in sync @@ -297,6 +306,17 @@ git checkout -- internal/handlers/auth.go - [ ] Immediately verify by reading back modified sections - [ ] Confirm ALL expected columns are present - [ ] Verify schema.sql, models.go, and queries.sql are in sync +- [ ] **Update local database** (choose ONE): + - [ ] **Option 1 - Recreate database** (recommended, loses data): + ```bash + podman compose down -v # Delete all volumes + podman compose up -d # Start with fresh schema + ``` + - [ ] **Option 2 - Manual SQL migration** (preserves data): + ```bash + podman exec bookhoard_db psql -U postgres -d bookhoard -c "YOUR SQL HERE" + ``` +- [ ] Verify database has new schema (check column types, indexes, etc.) ### After API Changes - [ ] Create/update Bruno DSL .bru requests