costco-grocery-list/docs/migration/POST_MIGRATION_UPDATES.md
2026-01-27 00:03:58 -08:00

84 lines
2.7 KiB
Markdown

# Post-Migration Updates Required
This document outlines the remaining updates needed after migrating to the multi-household architecture.
## ✅ Completed Fixes
1. **Column name corrections** in `list.model.v2.js`:
- Fixed `item_image``custom_image`
- Fixed `image_mime_type``custom_image_mime_type`
- Fixed `hlh.list_id``hlh.household_list_id`
2. **SQL query fixes**:
- Fixed ORDER BY with DISTINCT in `getSuggestions`
- Fixed `setBought` to use boolean instead of quantity logic
3. **Created migration**: `add_notes_column.sql` for missing notes column
## 🔧 Required Database Migration
**Run this SQL on your PostgreSQL database:**
```sql
-- From backend/migrations/add_notes_column.sql
ALTER TABLE household_lists
ADD COLUMN IF NOT EXISTS notes TEXT;
COMMENT ON COLUMN household_lists.notes IS 'Optional user notes/description for the item';
```
## 🧹 Optional Cleanup (Not Critical)
### Legacy Files Still Present
These files reference the old `grocery_list` table but are not actively used by the frontend:
- `backend/models/list.model.js` - Old model
- `backend/controllers/lists.controller.js` - Old controller
- `backend/routes/list.routes.js` - Old routes (still mounted at `/list`)
**Recommendation**: Can be safely removed once you confirm the new architecture is working, or kept as fallback.
### Route Cleanup in app.js
The old `/list` route is still mounted in `backend/app.js`:
```javascript
const listRoutes = require("./routes/list.routes");
app.use("/list", listRoutes); // ← Not used by frontend anymore
```
**Recommendation**: Comment out or remove once migration is confirmed successful.
## ✅ No Frontend Changes Needed
The frontend is already correctly calling the new household-scoped endpoints:
- All calls use `/households/:householdId/stores/:storeId/list/*` pattern
- No references to old `/list/*` endpoints
## 🎯 Next Steps
1. **Run the notes column migration** (required for notes feature to work)
2. **Test the application** thoroughly:
- Add items with images
- Mark items as bought/unbought
- Update item quantities and notes
- Test suggestions/autocomplete
- Test recently bought items
3. **Remove legacy files** (optional, once confirmed working)
## 📝 Architecture Notes
**Current Structure:**
- All list operations are scoped to `household_id + store_id`
- History tracking uses `household_list_history` table
- Image storage uses `custom_image` and `custom_image_mime_type` columns
- Classifications use `household_item_classifications` table (per household+store)
**Middleware Chain:**
```javascript
auth householdAccess storeAccess controller
```
This ensures users can only access data for households they belong to and stores linked to those households.