8.2 KiB
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_columnmappings - Added: Comprehensive CHOICES (4 types, 14 structures)
- Updated: Defaults to
post/article
✅ /backend/igny8_core/business/content/models.py - Tasks & Content
- Tasks: Removed
db_columnmappings forcontent_typeandcontent_structure - Content: Removed
db_columnmapping forcontent_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_structuremapping 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_rolemapping - 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, articlespage- Static pagesproduct- Product pagestaxonomy- Category/tag/attribute archives
Content Structures (14)
Post Structures (5):
article- Standard blog postguide- How-to guidescomparison- Comparison postsreview- Review postslisticle- List-based articles
Page Structures (5):
landing_page- Marketing landing pagesbusiness_page- Business info pagesservice_page- Service description pagesgeneral- General static pagescluster_hub- Topic cluster hub pages
Product Structures (1):
product_page- Product detail pages
Taxonomy Structures (3):
category_archive- Category listing pagestag_archive- Tag listing pagesattribute_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:
igny8_content_ideas(2 columns)igny8_tasks(2 columns)igny8_content(3 columns)igny8_content_taxonomy_map(1 column)igny8_taxonomy_terms(1 column)
How to Execute
# 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
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:
-
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
- GET
-
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
- GET
-
Content API:
- GET
/api/writer/content/- List content - GET
/api/writer/content/?content_type=page- Filter by type
- GET
Frontend Testing
-
Navigate to Ideas page - verify:
- Filters show all 14 structures
- Create form has all types/structures
- Table displays correctly
- Bulk queue works
-
Navigate to Tasks page - verify:
- Filters work with new values
- Table columns show type/structure badges
- No console errors
-
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:
- Reverse SQL migration (see
rename_fields_migration.sqlcomments) - Revert all code changes via git
- 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
- ✅ All code changes complete
- ⏳ Execute SQL migration
- ⏳ Run backend test script
- ⏳ Test APIs manually
- ⏳ Test frontend pages
- ⏳ Verify no 500/403 errors
- ⏳ Update any external documentation
- ⏳ 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