ALTER TABLE `credit_transactions` 
ADD COLUMN `sale_id` int(11) DEFAULT NULL AFTER `type`,
ADD CONSTRAINT `credit_transactions_sale_fk` 
FOREIGN KEY (`sale_id`) REFERENCES `sales` (`sale_id`) 
ON DELETE SET NULL; 