Database Migration Center

Database Migration Center

This page manages database migrations for the system. Each migration is run independently with proper error handling.

🔧 New Generic Tool Available: Add Any Column to Any Table - Universal form-based tool for adding columns to all agency databases with SQL preview.

Running Migration: #migrationName#

SELECT DISTINCT Agency_ID, Agency_Name FROM #Request.prefix_db_lookup#.Agency WHERE Status = 'active' ORDER BY Agency_ID
Found #getAgencies.recordCount# active agencies to migrate

Processing Agency: #Agency_Name# (ID: #Agency_ID#)

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '#agencyDbName#' AND TABLE_NAME = 'pPayer' AND COLUMN_NAME = 'EVV_Payer_ID' ALTER TABLE #agencyDbName#.pPayer ADD COLUMN EVV_Payer_ID VARCHAR(50) NULL AFTER EVV
✓ Added EVV_Payer_ID column to #agencyDbName#.pPayer
ALTER TABLE #agencyDbName#.pPayer MODIFY COLUMN EVV_Payer_ID VARCHAR(50) NULL COMMENT 'EVV Payer ID for visit transmission when EVV is enabled'
✓ Added comment to EVV_Payer_ID column in #agencyDbName#
CREATE INDEX idx_evv_payer_id ON #agencyDbName#.pPayer(EVV_Payer_ID)
✓ Created index on EVV_Payer_ID in #agencyDbName#
✓ EVV_Payer_ID column already exists in #agencyDbName# - skipping
✗ Failed to migrate #agencyDbName#: #cfcatch.message#
DESCRIBE #Request.prefix_db_agency#.pPayer

Column Verification:

Field Type Null Key Default Extra
#Field# #Type# #Null# #Key# #Default# #Extra#
✓ EVV Payer ID Migration completed successfully!

The EVV_Payer_ID column has been added to the pPayer table and is ready for use.

SELECT DISTINCT table_schema as db_name FROM information_schema.tables WHERE table_name = 'pSchedules' AND table_schema LIKE 'agency_%' AND table_schema NOT LIKE '%lookup%' ORDER BY table_schema
Found #getAgencies.recordCount# agency databases to migrate

Processing Database: #db_name#

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = '#db_name#' AND TABLE_NAME = 'pSchedules' AND COLUMN_NAME = 'unstable_action' ALTER TABLE #db_name#.pSchedules ADD COLUMN unstable_action VARCHAR(255) NULL COMMENT 'Clinician action for handling unstable problems'
✓ Added unstable_action column to #db_name#.pSchedules
CREATE INDEX idx_unstable_action ON #db_name#.pSchedules(unstable_action)
✓ Created index on unstable_action in #db_name#
✓ Index already exists or couldn't be created in #db_name# (not critical)
✓ unstable_action column already exists in #db_name# - skipping
✗ Failed to migrate #db_name#: #cfcatch.message#
✓ Unstable Action Field Migration Summary:
- Total Agencies: #getAgencies.recordCount#
- Successfully Added: #successCount#
- Already Existed (Skipped): #skipCount#
✓ Future migration 1 completed successfully!
✓ Future migration 2 completed successfully!
✗ Unknown migration type: #migrationType#
✗ Migration failed: #cfcatch.message#
Detail: #cfcatch.detail#
SQL State: #cfcatch.sqlState#
Error Code: #cfcatch.errorCode#
EVV Payer ID Migration
Adds EVV_Payer_ID column to pPayer table for ALL active agencies. This stores EVV payer identifiers when EVV is enabled for each agency.
-- Add EVV_Payer_ID column to pPayer table (after EVV column) ALTER TABLE pPayer ADD COLUMN EVV_Payer_ID VARCHAR(50) NULL AFTER EVV; -- Add comment to document the field purpose ALTER TABLE pPayer MODIFY COLUMN EVV_Payer_ID VARCHAR(50) NULL COMMENT 'EVV Payer ID for visit transmission when EVV is enabled'; -- Create index for better performance on EVV_Payer_ID lookups CREATE INDEX idx_evv_payer_id ON pPayer(EVV_Payer_ID);
🔧 Generic Column Creator Tool (Universal)
Add ANY column to ANY table for all agency databases with a user-friendly form interface.
  • ✨ Choose table name dynamically
  • 📝 Specify column name, type, nullable, default value
  • 💬 Add comments and position (AFTER clause)
  • 📊 Optional index creation
  • 🔍 SQL preview before execution
  • ✅ Safe: Checks for existing columns
Perfect for: Any future column additions without creating new migration files!
-- Dynamically generated based on your form input -- Example: ALTER TABLE {agency_db}.pSchedules ADD COLUMN your_column_name VARCHAR(255) NULL COMMENT 'Your description'; CREATE INDEX idx_your_column ON {agency_db}.pSchedules(your_column_name);
🚀 Open Generic Column Tool
Add Unstable Action Field to pSchedules
Adds unstable_action column to pSchedules table for ALL agency databases. This field stores the clinician's action for handling unstable problems (vitals/symptoms) during patient visits:
  • "Re-evaluate at next visit. Do not report to physician."
  • "Report unstable problems to physician"
Affected: All agency databases (agency_*)
Table: pSchedules
-- Add unstable_action column to pSchedules table ALTER TABLE {agency_db}.pSchedules ADD COLUMN unstable_action VARCHAR(255) NULL COMMENT 'Clinician action for handling unstable problems'; -- Create index for better performance CREATE INDEX idx_unstable_action ON {agency_db}.pSchedules(unstable_action);
Standalone Version
Future Migration Template
Template for future database migrations. Copy this structure for new migrations.
-- Example future migration -- ALTER TABLE example_table ADD COLUMN new_field VARCHAR(100) NULL; -- CREATE INDEX idx_new_field ON example_table(new_field);
Important: Always backup your database before running any migrations. This tool is designed to be safe and will check for existing columns before creating them.

← Back to Payer List