Refactor: Implement logging and JSONB cleanup

This commit is contained in:
gpt-engineer-app[bot]
2025-11-03 18:05:58 +00:00
parent b6179372e6
commit e9b9faa3e1
18 changed files with 430 additions and 142 deletions

View File

@@ -5,47 +5,58 @@
---
## 📊 Current JSONB Violations
## 📊 Current JSONB Status
### ✅ ALL VIOLATIONS ELIMINATED
### ✅ Acceptable JSONB Usage (Configuration Objects Only)
**Status**: COMPLETE ✅
All JSONB violations have been successfully eliminated. See `PHASE_1_JSONB_ELIMINATION_COMPLETE.md` for details.
These JSONB columns store non-relational configuration data:
### Previously Fixed (Now Relational)
-`rides.coaster_stats``ride_coaster_stats` table
-`rides.technical_specs``ride_technical_specifications` table
**User Preferences**:
-`user_preferences.unit_preferences`
-`user_preferences.privacy_settings`
-`user_preferences.email_notifications`
-`user_preferences.push_notifications`
-`user_preferences.accessibility_options`
**System Configuration**:
-`admin_settings.setting_value`
-`notification_channels.configuration`
-`user_notification_preferences.channel_preferences`
-`user_notification_preferences.frequency_settings`
-`user_notification_preferences.workflow_preferences`
**Test & Metadata**:
-`test_data_registry.metadata`
### ❌ JSONB Violations (Relational Data Stored as JSON)
**Critical Violations** - Should be relational tables:
-`content_submissions.content` - Submission data (should be `submission_metadata` table)
-`contact_submissions.submitter_profile_data` - Should be foreign key to `profiles`
-`reviews.photos` - Should be `review_photos` table
-`notification_logs.payload` - Should be type-specific event tables
-`historical_parks.final_state_data` - Should be relational snapshot
-`historical_rides.final_state_data` - Should be relational snapshot
-`entity_versions_archive.version_data` - Should be relational archive
-`item_edit_history.changes` - Should be `item_change_fields` table
-`admin_audit_log.details` - Should be relational audit fields
-`moderation_audit_log.metadata` - Should be relational audit data
-`profile_audit_log.changes` - Should be `profile_change_fields` table
-`request_metadata.breadcrumbs` - Should be `request_breadcrumbs` table
-`request_metadata.environment_context` - Should be relational fields
-`contact_email_threads.metadata` - Should be relational thread data
-`conflict_resolutions.conflict_details` - Should be relational conflict data
**View Aggregations** - Acceptable (read-only views):
-`moderation_queue_with_entities.*` - VIEW that aggregates data (not a table)
### Previously Migrated to Relational Tables ✅
-`rides.coaster_stats``ride_coaster_statistics` table
-`rides.technical_specs``ride_technical_specifications` table
-`ride_models.technical_specs``ride_model_technical_specifications` table
-`user_top_lists.items``list_items` table
-`user_top_lists.items``user_top_list_items` table
-`rides.former_names``ride_name_history` table
### Migration Status
-**Phase 1**: Relational tables created (COMPLETE)
-**Phase 2**: Data migration scripts (COMPLETE)
-**Phase 3**: JSONB columns dropped (COMPLETE)
-**Phase 4**: Application code updated (COMPLETE)
-**Phase 5**: Edge functions updated (COMPLETE)
---
## ✅ Acceptable JSONB Usage
These are the ONLY approved JSONB columns (configuration objects, no relational structure):
### User Preferences (Configuration)
-`user_preferences.unit_preferences` - User measurement preferences
-`user_preferences.privacy_settings` - Privacy configuration
-`user_preferences.notification_preferences` - Notification settings
### System Configuration
-`admin_settings.setting_value` - System configuration values
-`notification_channels.configuration` - Channel config objects
-`admin_audit_log.details` - Audit metadata (non-queryable)
### Legacy Support (To Be Eliminated)
- ⚠️ `content_submissions.content` - Has strict validation, but should migrate to `submission_metadata` table
- ⚠️ `rides.former_names` - Array field, should migrate to `entity_former_names` table
---
## 🎯 Refactoring Plan