ServerDynamic Objects
Runbook
Troubleshooting and maintenance for Dynamic Objects.
Troubleshooting
Validation Cache Outdated
Symptoms: Requests fail with "Field mismatch" or "Validation error"
Diagnosis:
- Check what schema the server has:
GET /api/v1/metadata/fields?entity=Invoice - Compare with database
Fieldrecords
Resolution:
- Restart server to clear in-memory cache
- Or trigger cache invalidation for tenant/entity
Slow Lookups
Symptoms: findMany on lookup fields taking > 500ms
Diagnosis:
- Check for missing indexes on tenant table
- Check validation cache hit rate
Resolution:
-- Check indexes on tenant table
SELECT indexname, indexdef
FROM pg_indexes
WHERE tablename = 'invoice';
-- Add index if missing
CREATE INDEX idx_invoice_customer ON invoice(customer_id);Migration Failures
Symptoms: New field appears in UI but requests fail with column does not exist
Diagnosis:
# Check server logs for MigrationError
grep "MigrationError" /var/log/crm/server.logResolution:
- Check tenant database schema:
SELECT column_name, data_type FROM information_schema.columns WHERE table_name = 'invoice'; - Re-trigger migration:
// Re-save the field to trigger hook await FieldService.updateField(fieldId, { ... });
Maintenance
Adding a New Field Type
- Update shared types: Add to
FieldTypeenum in@repo/shared-types - Update EntityMetadataService: Handle new type in
getFields - Update ValidationService: Map type to JSON Schema property
- Update Migration Engine: Generate correct DDL for type
Manual Schema Sync
If tenant schema drifts from metadata:
import { TenantMigrationService } from "./services/migration-service";
await TenantMigrationService.syncSchema({
org: "acme-corp",
entity: "Invoice",
});Database Commands
# Access tenant database
pnpm db:org:push # Push schema to org DB
pnpm db:org:studio # Open Prisma Studio for org DB