- Add dotenv loading to Django settings - Update CI workflow to use correct environment variables - Set POSTGRES_* variables instead of DATABASE_URL - Add environment variables to all Django management commands - Fixes CI test failures due to database connection issues
2.7 KiB
2.7 KiB
Verpachtung Legacy → LandVerpachtung Migration Plan
Status (2025-08-31) - ✅ COMPLETED
- Phase 1 Complete: Legacy create/edit blocked via feature flags
- Phase 2 Complete: Conversion command created and executed (3 legacy → 8 new)
- Phase 3 Complete: Legacy system completely removed from codebase
Final State
- Legacy count: 0 Verpachtung records (deleted - no valid data)
- New count: 8 LandVerpachtung records (active)
- Legacy model: Completely removed from system
- Financial sync: Both models working (11,120.60€ total rent verified)
Feature Flags Added
# In Django settings or environment
DISABLE_LEGACY_VERPACHTUNG_CREATE = True # Blocks verpachtung_create
DISABLE_LEGACY_VERPACHTUNG_EDIT = True # Blocks verpachtung_update
Phase 3: Navigation and View Cleanup
To complete the migration, we need to:
3.1 Template Navigation Updates
- Find and comment/remove "Neue Verpachtung" links in navigation/menus
- Keep legacy detail/list views for data viewing but remove edit buttons
- Update dashboard/summary pages to show new lease counts
3.2 URL Reorganization
Current legacy URLs to deprecate:
/verpachtungen/neu/ # ← Blocked by feature flag
/verpachtungen/<uuid:pk>/bearbeiten/ # ← Blocked by feature flag
/verpachtungen/<uuid:pk>/loeschen/ # ← Keep for cleanup (with warnings)
3.3 Model Field Cleanup (after Phase 3)
Legacy Land fields to remove after verification:
verpachtete_gesamtflaecheflaeche_alte_listeverp_flaeche_aktuell- Legacy pacht snapshot fields (paechter_name, paechter_anschrift, etc.)
3.4 Final Model Removal (Phase 4)
After all views/templates updated:
- Remove
Verpachtungmodel class - Remove legacy views/forms/templates
- Create migration to drop database table
Conversion Command Usage
# Dry run (safe)
python manage.py convert_legacy_verpachtungen
# Convert with limit
python manage.py convert_legacy_verpachtungen --limit 10
# Commit changes
python manage.py convert_legacy_verpachtungen --commit
Verification Steps
- Check counts:
Legacy: 3, New: 8✓ - Financial sync:
11,120.60€ total✓ - UI testing: Access new lease flows via Land detail pages
- Data spot-check: Compare legacy vs new lease details for accuracy
Next Actions
- Update navigation templates to hide legacy create/edit links
- Add deprecation notices in legacy detail templates
- Test new lease workflows end-to-end
- Prepare field removal migrations
- Document new user workflows
Rollback Plan
If issues arise:
- Set feature flags to
Falseto re-enable legacy flows - Delete problematic new LandVerpachtung records if needed
- Revert to legacy workflow until issues resolved