-- Adds submitted-gold capture support for existing loan databases.

ALTER TABLE `loans`
  MODIFY `loan_status` enum('active','closed','cancelled','captured') NOT NULL DEFAULT 'active';

CREATE TABLE IF NOT EXISTS `loan_gold_captures` (
  `cap_id` int NOT NULL AUTO_INCREMENT,
  `cap_loan_id` int NOT NULL,
  `cap_date` date NOT NULL,
  `cap_gold_value` decimal(12,2) NOT NULL DEFAULT '0.00',
  `cap_remarks` text,
  `cap_by` int DEFAULT NULL,
  `cap_dt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`cap_id`),
  KEY `cap_loan_id` (`cap_loan_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
