ALTER TABLE `orders`
ADD COLUMN `bhn_order_id` TEXT AFTER `incomm_order_uri`;

ALTER TABLE `egcards`
ADD COLUMN `bhn_order_id` TEXT AFTER `incomm_order_uri`;

ALTER TABLE `orders`
CHANGE COLUMN `system` `system` ENUM('cashstar', 'incomm', 'mixed', 'bhn' ) NULL DEFAULT 'cashstar' ;

ALTER TABLE `egcards`
CHANGE COLUMN `system` `system` ENUM('cashstar', 'incomm', 'mixed', 'bhn' ) NULL DEFAULT 'cashstar' ;

ALTER TABLE `brands`
CHANGE COLUMN `system` `system` ENUM('cashstar', 'incomm', 'mixed', 'bhn' ) NULL DEFAULT 'cashstar' ;

ALTER TABLE `brands`
ADD COLUMN `merchant_template_id` VARCHAR(255) AFTER `merchant_code`

CREATE TABLE `bhn_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `request_method` varchar(255) DEFAULT NULL,
  `request_url` varchar(255) DEFAULT NULL,
  `request_headers` text,
  `request_body` text,
  `response_status_code` int(3) DEFAULT NULL,
  `response_headers` text,
  `response_body` text,
  PRIMARY KEY (`id`),
  KEY `timestamp` (`timestamp`)
) ENGINE=InnoDB;

CREATE TABLE `bhn_settings` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `value` text NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB;
