refactor-migration again
This commit is contained in:
257
FIELD_RENAME_COMPLETE.md
Normal file
257
FIELD_RENAME_COMPLETE.md
Normal file
@@ -0,0 +1,257 @@
|
||||
# Field Rename Implementation Complete
|
||||
|
||||
## Summary
|
||||
Complete removal of old field names (`site_entity_type`, `cluster_role`, `entity_type`, `html_content`) with NO backward compatibility. All references updated to use new field names (`content_type`, `content_structure`, `content_html`) across entire codebase.
|
||||
|
||||
## Changes Completed
|
||||
|
||||
### Backend Models (3 files)
|
||||
✅ `/backend/igny8_core/business/planning/models.py` - ContentIdeas
|
||||
- Renamed: `site_entity_type` → `content_type`
|
||||
- Renamed: `cluster_role` → `content_structure`
|
||||
- Removed: ALL `db_column` mappings
|
||||
- Added: Comprehensive CHOICES (4 types, 14 structures)
|
||||
- Updated: Defaults to `post` / `article`
|
||||
|
||||
✅ `/backend/igny8_core/business/content/models.py` - Tasks & Content
|
||||
- Tasks: Removed `db_column` mappings for `content_type` and `content_structure`
|
||||
- Content: Removed `db_column` mapping for `content_html`
|
||||
- Added: Comprehensive CHOICES to both models
|
||||
- Updated: All help text
|
||||
|
||||
### Backend Views & Services (5 files)
|
||||
✅ `/backend/igny8_core/modules/planner/views.py`
|
||||
- Removed: `role_to_structure` mapping dict
|
||||
- Direct field copy now: `idea.content_type` → `task.content_type`
|
||||
|
||||
✅ `/backend/igny8_core/modules/planner/serializers.py`
|
||||
- Already using correct field names
|
||||
|
||||
✅ `/backend/igny8_core/ai/functions/generate_ideas.py`
|
||||
- Removed: `structure_to_role` mapping
|
||||
- Direct assignment of `content_type`/`content_structure`
|
||||
|
||||
✅ `/backend/igny8_core/business/publishing/services/adapters/sites_renderer_adapter.py`
|
||||
- Updated: All `entity_type` → `content_type`
|
||||
- Updated: All `cluster_role` → `content_structure`
|
||||
- Removed: All backward compatibility logic
|
||||
|
||||
✅ `/backend/igny8_core/business/site_building/services/page_generation_service.py`
|
||||
- Updated: `entity_type` → `content_type`
|
||||
- Updated: `cluster_role` → `content_structure`
|
||||
- Removed: Old field references
|
||||
|
||||
### Backend AI & Prompts (2 files)
|
||||
✅ `/backend/igny8_core/ai/prompts.py`
|
||||
- Updated: Documentation for new values
|
||||
- Updated: Prompt templates to reference `content_structure`
|
||||
- Removed: Old hub/supporting/attribute references
|
||||
|
||||
### Frontend TypeScript Interfaces (1 file)
|
||||
✅ `/frontend/src/services/api.ts`
|
||||
- Updated: `ContentIdea`, `ContentIdeaCreateData`, `ContentIdeasFilters`
|
||||
- All interfaces now use `content_type` / `content_structure`
|
||||
|
||||
### Frontend Pages (3 files)
|
||||
✅ `/frontend/src/pages/Planner/Ideas.tsx`
|
||||
- Updated: All 6 field references
|
||||
- Updated: Form data, filters, handlers
|
||||
|
||||
✅ `/frontend/src/pages/Sites/PostEditor.tsx`
|
||||
- Updated: `content.cluster_role` → `content.content_structure`
|
||||
|
||||
✅ `/frontend/src/pages/Settings/DebugStatus.tsx`
|
||||
- Updated: Help text to reference new field names
|
||||
- Noted old names as removed
|
||||
|
||||
### Frontend Config Files (4 files)
|
||||
✅ `/frontend/src/config/structureMapping.ts` - NEW
|
||||
- Created: Shared constants for all structure mappings
|
||||
- Exports: `CONTENT_TYPE_OPTIONS` (4 types)
|
||||
- Exports: `CONTENT_STRUCTURE_BY_TYPE` (14 structures)
|
||||
- Exports: `STRUCTURE_LABELS`, `TYPE_LABELS`, `getStructureOptions()`
|
||||
|
||||
✅ `/frontend/src/config/pages/ideas.config.tsx`
|
||||
- Updated: Interface, columns, filters, form fields
|
||||
- Comprehensive 14-structure options in filters and forms
|
||||
|
||||
✅ `/frontend/src/config/pages/tasks.config.tsx`
|
||||
- Updated: All references to use new field names
|
||||
- Comprehensive 14-structure options in filters and forms
|
||||
- Uses structureMapping constants
|
||||
|
||||
✅ `/frontend/src/config/pages/content.config.tsx`
|
||||
- Updated: All references to use new field names
|
||||
- Comprehensive 14-structure options in filters
|
||||
- Uses structureMapping constants
|
||||
|
||||
## New Value Schema
|
||||
|
||||
### Content Types (4)
|
||||
- `post` - Blog posts, articles
|
||||
- `page` - Static pages
|
||||
- `product` - Product pages
|
||||
- `taxonomy` - Category/tag/attribute archives
|
||||
|
||||
### Content Structures (14)
|
||||
|
||||
**Post Structures (5):**
|
||||
- `article` - Standard blog post
|
||||
- `guide` - How-to guides
|
||||
- `comparison` - Comparison posts
|
||||
- `review` - Review posts
|
||||
- `listicle` - List-based articles
|
||||
|
||||
**Page Structures (5):**
|
||||
- `landing_page` - Marketing landing pages
|
||||
- `business_page` - Business info pages
|
||||
- `service_page` - Service description pages
|
||||
- `general` - General static pages
|
||||
- `cluster_hub` - Topic cluster hub pages
|
||||
|
||||
**Product Structures (1):**
|
||||
- `product_page` - Product detail pages
|
||||
|
||||
**Taxonomy Structures (3):**
|
||||
- `category_archive` - Category listing pages
|
||||
- `tag_archive` - Tag listing pages
|
||||
- `attribute_archive` - Attribute filter pages
|
||||
|
||||
## Database Migration
|
||||
|
||||
### SQL Migration File
|
||||
✅ `/backend/rename_fields_migration.sql`
|
||||
- Renames 5 tables' columns
|
||||
- Conditional checks (only rename if old column exists)
|
||||
- Index renames
|
||||
- Tables affected:
|
||||
1. `igny8_content_ideas` (2 columns)
|
||||
2. `igny8_tasks` (2 columns)
|
||||
3. `igny8_content` (3 columns)
|
||||
4. `igny8_content_taxonomy_map` (1 column)
|
||||
5. `igny8_taxonomy_terms` (1 column)
|
||||
|
||||
### How to Execute
|
||||
```bash
|
||||
# Option 1: Via psql (if available)
|
||||
psql -U username -d database_name -f /data/app/igny8/backend/rename_fields_migration.sql
|
||||
|
||||
# Option 2: Via Django shell
|
||||
cd /data/app/igny8/backend
|
||||
source .venv/bin/activate
|
||||
python manage.py dbshell < rename_fields_migration.sql
|
||||
|
||||
# Option 3: Via Django migration (recommended)
|
||||
python manage.py makemigrations
|
||||
python manage.py migrate
|
||||
```
|
||||
|
||||
## Testing & Validation
|
||||
|
||||
### Backend Testing Script
|
||||
✅ `/backend/test_field_rename.py`
|
||||
- Tests model field access
|
||||
- Verifies database column names
|
||||
- Validates CHOICES definitions
|
||||
- Checks for old column names
|
||||
|
||||
### Run Test
|
||||
```bash
|
||||
cd /data/app/igny8/backend
|
||||
source .venv/bin/activate
|
||||
python manage.py shell < test_field_rename.py
|
||||
```
|
||||
|
||||
### Manual API Testing
|
||||
Test these endpoints after migration:
|
||||
|
||||
1. **Ideas API:**
|
||||
- GET `/api/planner/ideas/` - List ideas
|
||||
- POST `/api/planner/ideas/` - Create idea with new fields
|
||||
- POST `/api/planner/ideas/{id}/bulk_queue_to_writer/` - Queue to writer
|
||||
|
||||
2. **Tasks API:**
|
||||
- GET `/api/writer/tasks/` - List tasks
|
||||
- GET `/api/writer/tasks/?content_type=post` - Filter by type
|
||||
- GET `/api/writer/tasks/?content_structure=article` - Filter by structure
|
||||
|
||||
3. **Content API:**
|
||||
- GET `/api/writer/content/` - List content
|
||||
- GET `/api/writer/content/?content_type=page` - Filter by type
|
||||
|
||||
### Frontend Testing
|
||||
1. Navigate to Ideas page - verify:
|
||||
- Filters show all 14 structures
|
||||
- Create form has all types/structures
|
||||
- Table displays correctly
|
||||
- Bulk queue works
|
||||
|
||||
2. Navigate to Tasks page - verify:
|
||||
- Filters work with new values
|
||||
- Table columns show type/structure badges
|
||||
- No console errors
|
||||
|
||||
3. Navigate to Content page - verify:
|
||||
- Filters work
|
||||
- Table displays correctly
|
||||
- PostEditor shows content_structure
|
||||
|
||||
## Breaking Changes
|
||||
⚠️ **NO BACKWARD COMPATIBILITY** - This is a breaking change:
|
||||
- Old API field names (`site_entity_type`, `cluster_role`) no longer work
|
||||
- Old database columns will be renamed (data preserved)
|
||||
- Any external integrations must update to new field names
|
||||
|
||||
## Rollback Plan
|
||||
If issues occur:
|
||||
1. Reverse SQL migration (see `rename_fields_migration.sql` comments)
|
||||
2. Revert all code changes via git
|
||||
3. Original columns: `site_entity_type`, `cluster_role`, `entity_type`, `html_content`
|
||||
|
||||
## Files Modified
|
||||
**Backend (7 files):**
|
||||
- Models: 2 files
|
||||
- Views: 1 file
|
||||
- Serializers: 1 file (already correct)
|
||||
- Services: 2 files
|
||||
- AI: 2 files
|
||||
|
||||
**Frontend (8 files):**
|
||||
- Interfaces: 1 file
|
||||
- Pages: 3 files
|
||||
- Configs: 4 files (1 new)
|
||||
|
||||
**Database:**
|
||||
- SQL migration: 1 file (not yet executed)
|
||||
- Test script: 1 file
|
||||
|
||||
**Total: 17 files modified/created**
|
||||
|
||||
## Next Steps
|
||||
1. ✅ All code changes complete
|
||||
2. ⏳ Execute SQL migration
|
||||
3. ⏳ Run backend test script
|
||||
4. ⏳ Test APIs manually
|
||||
5. ⏳ Test frontend pages
|
||||
6. ⏳ Verify no 500/403 errors
|
||||
7. ⏳ Update any external documentation
|
||||
8. ⏳ Deploy to production
|
||||
|
||||
## Verification Checklist
|
||||
- [ ] SQL migration executed successfully
|
||||
- [ ] Backend test script passes
|
||||
- [ ] Ideas API works (list, create, bulk queue)
|
||||
- [ ] Tasks API works (list, filter by type/structure)
|
||||
- [ ] Content API works (list, filter)
|
||||
- [ ] Ideas page loads without errors
|
||||
- [ ] Tasks page loads without errors
|
||||
- [ ] Content page loads without errors
|
||||
- [ ] PostEditor displays content_structure
|
||||
- [ ] All filters show 14 structure options
|
||||
- [ ] No 500 errors in backend logs
|
||||
- [ ] No console errors in frontend
|
||||
- [ ] WordPress sync still works (if applicable)
|
||||
|
||||
---
|
||||
**Implementation Date:** 2024
|
||||
**Status:** CODE COMPLETE - AWAITING MIGRATION EXECUTION & TESTING
|
||||
Reference in New Issue
Block a user