Files
bookhoard/MIGRATION_FINAL_STATUS.md
T
john-okeefe f96044b6c7 refactor: remove ebook system, unify on media-items
Phase 1-3: Database layer cleanup
- Remove 5 backward compatibility VIEWs (ebooks, ebook_ratings, etc.)
- Remove all ebook-specific database queries
- Add new admin media-items queries (Create, Update, Delete)
- Fix sqlc.yaml to point to schema.sql file
- Regenerate database code successfully

Phase 4: Remove old ebook handlers
- Remove all 23 ebook handler functions:
  * ListEbooks, GetEbook, CreateEbook, UpdateEbook, DeleteEbook
  * GetEbookRating, CreateOrUpdateEbookRating, DeleteEbookRating, GetEbookRatings
  * GetEbookNotes, CreateEbookNote, GetEbookNote, UpdateEbookNote, DeleteEbookNote
  * GetEbookHighlights, CreateEbookHighlight, GetEbookHighlight, UpdateEbookHighlight, DeleteEbookHighlight
  * GetReadingProgress, UpdateReadingProgress
- Remove ebook request types (CreateEbookRequest, UpdateEbookRequest, etc.)

Phase 5: Add new admin media-items handlers
- CreateMediaItem (admin only, requires library_id)
- UpdateMediaItem (admin only)
- DeleteMediaItem (admin only)
- Add CreateMediaItemRequest, UpdateMediaItemRequest types
- All use MustGetAuthenticatedUser for safe context access
- Validate admin role before allowing operations
- Validate library exists before creating items

Phase 6: Update routes
- Remove ALL /api/ebooks routes from SetupRoutes()
- Remove ebook progress, rating, notes, highlights routes
- Add admin.POST/PUT/DELETE /api/media-items routes
- Keep all media-items, scanner, and watch mode routes intact

Result: Unified API with only /api/media-items endpoints
- All features preserved (filtering, sorting, searching)
- Better features than old ebook system (more fields, library scoping)
- Cleaner codebase with single system
- All code compiles successfully

Breaking Change: /api/ebooks endpoints removed (use /api/media-items instead)
Status: 85% complete (Phases 1-6 done, Phases 7-8 pending: tests + rebuild)

Tests: Need update (rename Ebooks → MediaItems, update API paths)
Build: Need rebuild with clean cache
2026-01-30 10:03:13 -05:00

116 lines
3.3 KiB
Markdown

# Ebook System Removal - FINAL STATUS
## ✅ COMPLETED (85%)
### Database Layer 100% Complete
- ✅ Removed 5 backward compatibility VIEWs
- ✅ Removed all ebook queries
- ✅ Added admin media-items queries
- ✅ Regenerated database code
- ✅ Schema is clean and ready
### Handler Layer 100% Complete
- ✅ Removed ALL 23 ebook handlers
- ✅ Kept all media-items handlers (intact)
- ✅ Added 3 new admin handlers:
- CreateMediaItem (admin only, requires library_id)
- UpdateMediaItem (admin only)
- DeleteMediaItem (admin only)
- ✅ All handlers now use MustGetAuthenticatedUser for safety
### Routes 100% Complete
- ✅ Removed ALL /api/ebooks routes from SetupRoutes()
- ✅ Added 3 admin media-items routes
- ✅ API is now unified: only /api/media-* endpoints
### Code Quality 100% Complete
- ✅ Compiles successfully
- ✅ No LSP errors
- ✅ All type safe
- ✅ No breaking changes to media-items functionality
## ⚠️ REMAINING (15%)
### Phase 7: Update Integration Tests (READY)
**File:** cmd/server/tests/integration_test.go
**Changes needed:**
1. Rename "Ebooks" test group (line 361) to "MediaItems"
2. Update test function name: testEbooks → testMediaItems (line 686)
3. Update all API paths:
- `/api/ebooks``/api/media-items`
- `/api/ebooks/:id``/api/media-items/:id`
- `/api/ebooks/:id/rating``/api/media-items/:id/rating`
- `/api/ebooks/:id/progress``/api/media-items/:id/progress`
4. Update TestContext field:
- `EbookID``MediaItemID` (line 32)
5. Add tests for new admin endpoints:
- POST /api/media-items (admin create)
- PUT /api/media-items/:id (admin update)
- DELETE /api/media-items/:id (admin delete)
6. Remove CreateEbook_UserForbidden test case
7. Add CreateMediaItem_UserForbidden test case
**Estimate:** ~20-30 minutes of systematic edits
### Phase 8: Build & Test (PENDING)
**Tasks:**
1. Stop current containers
2. Clean database and volumes
3. Rebuild with `--no-cache`
4. Start containers
5. Run integration tests
6. Fix any test failures
7. Verify all functionality
**Estimate:** ~10-15 minutes
## Summary
### What's Done
- Database is clean (no backward compatibility views)
- API is unified (only /api/media-items endpoints)
- All old ebook code removed
- New admin handlers added
- Code compiles cleanly
- Ready for test phase
### What's Left
1. Update integration tests (~20-30 min)
2. Rebuild & test (~10-15 min)
## Migration Benefits
### Before Removal
- ❌ Dual systems (ebooks + media-items)
- ❌ Backward compatibility views
- ❌ 23 redundant ebook handlers
- ❌ Inconsistent API paths
- ❌ More complex code to maintain
### After Removal
- ✅ Single unified system (media-items only)
- ✅ Clean database schema
- ✅ Consistent API paths
- ✅ Simpler codebase
- ✅ All features preserved + more (filtering, sorting, searching)
## Decision Point
**Current State:**
- All code changes complete
- Code compiles successfully
- Ready for test update phase
**Options:**
A) Continue now with test updates and complete migration
B) Commit current changes now, finish tests later
C) Stop now and review progress
**Recommendation:** Option A - Continue now (only 30-45 minutes to complete)
---
**Status:** Ready to complete
**Progress:** 85% complete, 15% remaining (tests + build)
**Quality:** High - all code compiles, no errors