-- Add new tables for trade references and bank details
CREATE TABLE IF NOT EXISTS `customer_trade_references` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customer_application_id` int(11) NOT NULL,
  `company_name` varchar(255) NOT NULL,
  `contact_person` varchar(255) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `phone` varchar(50) DEFAULT NULL,
  `address` text,
  PRIMARY KEY (`id`),
  KEY `customer_application_id` (`customer_application_id`),
  CONSTRAINT `customer_trade_references_ibfk_1` FOREIGN KEY (`customer_application_id`) REFERENCES `customer_applications` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

CREATE TABLE IF NOT EXISTS `customer_bank_details` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `customer_application_id` int(11) NOT NULL,
  `bank_name` varchar(255) DEFAULT NULL,
  `branch` varchar(255) DEFAULT NULL,
  `bsb_number` varchar(50) DEFAULT NULL,
  `account_number` varchar(50) DEFAULT NULL,
  `account_name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `customer_application_id` (`customer_application_id`),
  CONSTRAINT `customer_bank_details_ibfk_1` FOREIGN KEY (`customer_application_id`) REFERENCES `customer_applications` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Add columns for declaration and signature to customer_applications
ALTER TABLE `customer_applications`
ADD COLUMN `declaration_text` TEXT,
ADD COLUMN `signature_path` VARCHAR(255);