Skip to content

Commit 04ad25e

Browse files
committed
feedback regeneration issue is fixed
1 parent cf19095 commit 04ad25e

89 files changed

Lines changed: 1881 additions & 32 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€ŽBackend/RUN_MIGRATION.mdβ€Ž

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# πŸš€ How to Run the Feedback Status Migration
2+
3+
## βœ… Step-by-Step Instructions
4+
5+
### **1. Activate Virtual Environment**
6+
```bash
7+
cd /Users/yubraj/Developer/Coding/surmm/aipilot.v2/Backend
8+
9+
# Activate venv
10+
source venv/bin/activate
11+
```
12+
13+
### **2. Install Required Package (tenacity already in requirements.txt)**
14+
```bash
15+
# Tenacity is already in your requirements.txt, but make sure it's installed:
16+
pip install tenacity
17+
```
18+
19+
### **3. Run the Migration**
20+
```bash
21+
# Run the migration script
22+
python migrations/add_feedback_status_tracking.py
23+
```
24+
25+
### **4. Verify It Worked**
26+
You should see output like:
27+
```
28+
======================================================================
29+
πŸ”„ Adding status tracking to ai_feedback table...
30+
======================================================================
31+
32+
πŸ“ Step 1: Making feedback_data nullable...
33+
βœ… feedback_data is now nullable
34+
35+
πŸ“ Step 2: Adding status tracking columns...
36+
βœ… All columns added successfully
37+
38+
πŸ“ Step 3: Creating index for faster queries...
39+
βœ… Index created
40+
41+
πŸ“ Step 4: Setting timestamps for existing rows...
42+
βœ… Timestamps updated for existing feedback
43+
44+
======================================================================
45+
βœ… Migration completed successfully!
46+
======================================================================
47+
πŸ“Š XXX existing feedback rows marked as 'completed' (100%)
48+
```
49+
50+
### **5. Restart Your Backend**
51+
```bash
52+
# Stop your current backend (Ctrl+C if running)
53+
54+
# Start again
55+
uvicorn main:app --reload
56+
```
57+
58+
---
59+
60+
## πŸ” Verify in Database (Optional)
61+
62+
```sql
63+
-- Check new columns exist
64+
SELECT column_name, data_type, is_nullable
65+
FROM information_schema.columns
66+
WHERE table_name = 'ai_feedback'
67+
AND column_name IN ('generation_status', 'generation_progress', 'error_message');
68+
69+
-- Check existing feedback
70+
SELECT
71+
id,
72+
generation_status,
73+
generation_progress,
74+
completed_at
75+
FROM ai_feedback
76+
LIMIT 5;
77+
```
78+
79+
---
80+
81+
## πŸ”„ If You Need to Rollback
82+
83+
```bash
84+
python migrations/add_feedback_status_tracking.py down
85+
```
86+
87+
---
88+
89+
## ⚠️ Troubleshooting
90+
91+
### Error: "relation already exists" or "column already exists"
92+
**Solution:** Migration already ran! You're good to go.
93+
94+
### Error: "column feedback_data must have a default value"
95+
**Solution:** The migration handles this by making it nullable first.
96+
97+
### Error: "permission denied"
98+
**Solution:** Make sure your database user has ALTER TABLE permissions.
99+
100+
---
101+
102+
## βœ… What Happens to Existing Data?
103+
104+
- **SAFE:** All existing feedback rows are preserved
105+
- **SAFE:** All existing `feedback_data` content stays intact
106+
- **SAFE:** Existing rows marked as `status='completed'`, `progress=100`
107+
- **SAFE:** Timestamps set to match `generated_at` for existing rows
108+
- **SAFE:** No data loss - migration only ADDS columns
109+
110+
---
111+
112+
## 🎯 Ready to Test!
113+
114+
After migration:
115+
1. Backend will start using new status tracking automatically
116+
2. Submit a new answer with `generate_feedback=true`
117+
3. Poll `/api/feedback/status/answer/{answer_id}` to see progress
118+
4. Old feedback will still display normally
119+
120+
**All set!** πŸš€
-1 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
-1 Bytes
Binary file not shown.
-1 Bytes
Binary file not shown.
-1 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
Binary file not shown.
2 Bytes
Binary file not shown.

0 commit comments

Comments
Β (0)