Add brand analysis columns to onboarding database and migration scripts
This commit is contained in:
63
docs/STEP_2_COLUMN_ERROR_FIX.md
Normal file
63
docs/STEP_2_COLUMN_ERROR_FIX.md
Normal file
@@ -0,0 +1,63 @@
|
||||
# Step 2 Column Error Fix
|
||||
|
||||
## Problem
|
||||
|
||||
After adding `brand_analysis` and `content_strategy_insights` columns to the `WebsiteAnalysis` model, the `/api/onboarding/style-detection/session-analyses` endpoint is failing with:
|
||||
|
||||
```
|
||||
ERROR|website_analysis_service.py:164:get_session_analyses| Error retrieving analyses for session 360913797: (sqlite3.OperationalError) no such column: website_analyses.brand_analysis
|
||||
```
|
||||
|
||||
## Root Cause
|
||||
|
||||
The `WebsiteAnalysisService` is trying to query the `website_analyses` table, but there's a mismatch between:
|
||||
|
||||
1. **Model Definition**: Includes `brand_analysis` and `content_strategy_insights` columns
|
||||
2. **Database Schema**: The columns exist (verified by migration script)
|
||||
3. **Runtime**: SQLAlchemy is failing to find the columns
|
||||
|
||||
## Possible Causes
|
||||
|
||||
1. **Multiple Database Files**: The service might be connecting to a different database file than the one we migrated
|
||||
2. **Connection Caching**: SQLAlchemy might be using cached schema information
|
||||
3. **Backend Restart Needed**: The model changes require a backend restart
|
||||
|
||||
## Solution
|
||||
|
||||
**Restart the backend server** to reload the updated model definitions and database connections.
|
||||
|
||||
### Steps
|
||||
|
||||
1. **Stop the current backend server** (Ctrl+C)
|
||||
2. **Start the backend server**:
|
||||
```bash
|
||||
python backend/start_alwrity_backend.py
|
||||
```
|
||||
|
||||
## Verification
|
||||
|
||||
After restart, the `/api/onboarding/style-detection/session-analyses` endpoint should work without errors.
|
||||
|
||||
## What We Kept
|
||||
|
||||
- ✅ **New database columns**: `brand_analysis` and `content_strategy_insights`
|
||||
- ✅ **Migration completed**: Columns exist in database
|
||||
- ✅ **Model updated**: `WebsiteAnalysis` includes new fields
|
||||
- ✅ **Service updated**: `OnboardingDatabaseService` saves new fields
|
||||
|
||||
## What We Reverted
|
||||
|
||||
- 🔄 **Data transformation**: Back to simple `step.data` passing
|
||||
- 🔄 **Check-existing endpoint**: Back to original SHA256 approach
|
||||
|
||||
## Expected Result
|
||||
|
||||
After restart:
|
||||
- ✅ **Existing analysis cache works** (Step 2)
|
||||
- ✅ **Step 6 data retrieval works** (FinalStep)
|
||||
- ✅ **Complete data saved** (including brand analysis)
|
||||
- ✅ **No breaking changes** (Steps 1-5)
|
||||
|
||||
---
|
||||
|
||||
**Next Action**: Restart backend server and test both Step 2 and Step 6.
|
||||
Reference in New Issue
Block a user