quantum-ai-v2/data_analyzer/migrations/0004_fix_duplicate_fields.py
Claude 4e7e43c436 Implement PostgreSQL development parity and fix migration conflicts
**PostgreSQL Development Setup:**
- Update .env with PostgreSQL configuration options
- Add comprehensive PostgreSQL setup guide (Docker + native)
- Configure development-production database parity

**Migration Conflict Resolution:**
- Create fix_migrations command to handle Railway migration conflicts
- Add reset_database command for clean development resets
- Update Railway deployment with migration conflict handling
- Add fake migration strategy for duplicate column errors

**New Management Commands:**
- `fix_migrations`: Diagnose and fix migration conflicts
- `reset_database`: Clean reset of migrations and database
- Support for both PostgreSQL and SQLite environments

**Railway Deployment Fixes:**
- Add migration conflict handling to railway.json
- Use --fake-initial and --fake strategies for deployment
- Better error recovery for existing schema conflicts

**Developer Experience:**
- Step-by-step PostgreSQL setup (Docker option for easy setup)
- Migration troubleshooting guide
- Development workflow documentation
- Local-production environment matching

**Fixes Railway Issue:**
- Resolves "column data_file already exists" error
- Handles existing database schema gracefully
- Prevents future migration conflicts

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-12 09:59:44 +05:30

25 lines
983 B
Python

# Generated manually to fix duplicate field migration errors
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('data_analyzer', '0003_dataanalysisagentrequest_input_text_and_more'),
]
operations = [
# This migration exists to mark the problematic fields as "already applied"
# It doesn't actually change anything, just syncs Django's migration state
# with the actual database schema
# The following fields already exist in the database but Django thinks they need to be added:
# - data_file (from 0002_auto_20250710_0431)
# - analysis_type (from 0002_auto_20250710_0431)
# - analysis_results (from 0002_auto_20250710_0431)
# - insights_summary (from 0002_auto_20250710_0431)
# - report_text (from 0002_auto_20250710_0431)
# This empty migration helps sync the state without actually changing the database
]