- Add admin dashboard with sync controls and data browser - Implement RMM, Auvik, and Addigy organization mappings - Add chunked ticket sync with progress tracking - Implement entity sync service with rate limiting - Add analytics engine and performance optimizer - Create data browser for all PSA entities - Add navigation components and UI improvements - Implement background processing and sync services - Add comprehensive documentation and migration scripts - Update configuration items with multi-system support - Enhance contact management and purchase history - Add issue type assignment and LLM analyzer - Improve error handling and logging utilities
1.4 KiB
1.4 KiB
Quick Fix for Ticket Sync Constraint Error
The Problem
Database error: insert or update on table "tickets" violates foreign key constraint "tickets_assigned_resource_id_fkey"
The Fix (2 Steps)
Step 1: Run Database Migration
docker exec pulse-app psql $DATABASE_URL -f /app/migrations/008_relax_tickets_resource_constraints.sql
Step 2: Restart the App (to load new code)
docker-compose restart app
Test the Fix
# Trigger a ticket sync
curl -X POST http://localhost:3000/api/sync/entity \
-H "Content-Type: application/json" \
-d '{"entities": ["tickets"], "yearsBack": 1, "triggeredBy": "admin"}'
# Watch the logs
docker logs -f pulse-app
What Changed
Database:
- Made resource foreign keys deferrable and lenient
- Tickets can now exist even if assigned resource doesn't exist
- Invalid resource IDs are set to NULL instead of causing failure
Application:
- Validates resource IDs before inserting tickets
- Logs warnings for tickets with invalid resource references
- Caches valid resource IDs for performance
Expected Results
✅ Ticket sync completes successfully
✅ Warnings logged for tickets with invalid resource IDs
✅ Those tickets have assigned_resource_id set to NULL
✅ All other ticket data is preserved
More Details
See /opt/stacks/pulse/docs/TICKET_SYNC_FIX.md for complete documentation.