Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
5.4 KiB
Reference Data Import System Migration Guide
Overview
This guide covers the migration process for existing installations to enable the new Reference Data Import System introduced in migration 20250630140000_create_standard_reference_tables.cjs.
What's New
The Reference Data Import System adds:
- Standard reference tables with pre-defined data
- Import functionality in the UI for all reference types
- Conflict resolution for handling duplicates
- Enhanced category management with parent-child relationships
- Display ordering for all reference data types
Migration Steps
1. Database Migration
Run the migration to create standard tables and update existing tables:
npm run db:migrate:latest
This migration will:
- Create
standard_*tables for all reference types - Add
display_ordercolumn to existing tables if missing - Add
descriptioncolumn to channels table - Populate standard tables with pre-defined data
- Update existing records with sequential display orders
2. Update Seed Files
If you use seed files, update them to include the new fields:
Channels
Add description and display_order:
{
channel_name: 'Technical Issues',
description: 'System failures, hardware issues, and technical problems',
display_order: 1
}
Categories
Add display_order and ensure channel_id is set:
{
category_name: 'Hardware',
channel_id: '<channel_uuid>',
display_order: 1,
created_by: '<user_uuid>'
}
Service Categories
Add display_order:
{
category_name: 'Managed Services',
description: 'Ongoing managed service offerings',
display_order: 1
}
3. UI Updates
The UI components are automatically updated with the migration. No manual changes needed.
4. Verify Installation
After migration:
- Navigate to Settings → General → Ticketing Settings
- Check each tab has the "Import from Standard Types" button
- Verify existing data has proper display orders
- Test importing a few standard items
Breaking Changes
Required Fields
The following fields are now required:
-
Categories
channel_id- Every category must belong to a channelcreated_by- User who created the category
-
All Reference Types
display_order- Defaults to 0 if not specified
API Changes
If you have custom API integrations:
- Category Creation - Must include
channel_id - Import Endpoints - New endpoints available:
POST /api/reference-data/availablePOST /api/reference-data/check-conflictsPOST /api/reference-data/import
Rollback Procedure
If you need to rollback:
npm run db:migrate:rollback
This will:
- Drop all
standard_*tables - Remove
display_ordercolumns - Remove
descriptionfrom channels
Warning: Rollback will lose any imported standard data.
Post-Migration Tasks
1. Review Display Orders
The migration assigns sequential orders to existing data. Review and adjust if needed:
- Go to each reference data settings page
- Review the order column
- Edit items to adjust ordering
2. Import Standard Data
Take advantage of pre-defined configurations:
- Click "Import from Standard Types"
- Select relevant items for your organization
- Resolve any conflicts
- Customize as needed
3. Update Documentation
Update your internal documentation to reflect:
- New import functionality
- Category channel requirements
- Display order management
Troubleshooting
Migration Fails
Error: "column already exists"
- The migration may have partially completed
- Check which tables were created
- Manually drop partial tables and re-run
Error: "null value in column 'created_by'"
- Ensure all categories have a valid created_by user
- Update existing records before migration
Import Issues
"No standard items available"
- Verify migration completed successfully
- Check standard tables have data:
SELECT COUNT(*) FROM standard_channels; SELECT COUNT(*) FROM standard_categories;
Import fails with constraint errors
- Check tenant context is set
- Verify user has appropriate permissions
- Review server logs for detailed errors
Performance Concerns
The standard tables are relatively small and indexed appropriately. If you experience performance issues:
-
Check indexes are created:
\d standard_categories -
Analyze query performance:
EXPLAIN ANALYZE SELECT * FROM standard_categories WHERE ...
Best Practices
For New Installations
- Run migrations before seeding
- Use import functionality instead of manual entry
- Customize after importing
For Existing Installations
- Backup database before migration
- Test in staging environment first
- Communicate changes to users
- Plan for training on new features
Ongoing Maintenance
- Review standard data with each upgrade
- Keep display orders logical
- Document any customizations
- Use consistent naming conventions
Support
For issues or questions:
- Check the Reference Data Import System documentation
- Review the Settings Reference Data Guide
- Check server logs for detailed error messages
- Contact support with migration version and error details