-- Preserve the ZYT fulfillment status before an EJ pharmacy submission. -- EJ review rejection restores this value; it is not customer refusal. SET @schema_name := DATABASE(); SET @ddl := IF( EXISTS ( SELECT 1 FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = @schema_name AND TABLE_NAME = 'zyt_tcm_prescription_order' AND COLUMN_NAME = 'ej_pharmacy_previous_fulfillment_status' ), 'SELECT 1', 'ALTER TABLE `zyt_tcm_prescription_order` ADD COLUMN `ej_pharmacy_previous_fulfillment_status` tinyint unsigned NULL DEFAULT NULL COMMENT ''Fulfillment status before EJ pharmacy submission'' AFTER `ej_pharmacy_status_version`' ); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt;