USE `registration`;
CREATE TABLE `license` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `order_reference` varchar(50) DEFAULT NULL,
  `product` varchar(100) NOT NULL DEFAULT '' COMMENT 'sp|mt|mao|mp|tlv',
  `version` int(11) NOT NULL,
  `license_type` varchar(15) NOT NULL DEFAULT 'single' COMMENT 'single|5-user|site',
  `acquisition_type` varchar(2) NOT NULL DEFAULT 'sl' COMMENT 'sl|up|cp',
  `email` varchar(100) DEFAULT NULL,
  `name` varchar(100) NOT NULL DEFAULT '',
  `quantity` int(11) DEFAULT NULL,
  `license_key` varchar(64) DEFAULT NULL COMMENT 'Registration Code',
  `license_data` text COMMENT 'Aquatic prime data',
  `name_key_hash` varchar(64) DEFAULT NULL COMMENT 'md5 hash of user+code',
  `previous_license` int (11) DEFAULT NULL,
  `bundle` varchar(10) DEFAULT NULL,
  `is_eligible_for_upgrade` tinyint(1) NOT NULL DEFAULT '0',
  `is_test` tinyint(1) DEFAULT NULL,
  `date` timestamp NULL DEFAULT NULL COMMENT 'unix timestamp',
  PRIMARY KEY (`id`),
  KEY `Email` (`email`),
  KEY `Name` (`name`),
  KEY `Reference` (`order_reference`)
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8;


-- Changes for Email handling (11 Jan 2022)

ALTER TABLE `registration`.`license`
	ADD COLUMN `domain` VARCHAR(100) DEFAULT '' AFTER `email`,
	ADD COLUMN `email_hash` VARCHAR(100) DEFAULT '' AFTER `domain`,
	ADD COLUMN `email_enc` VARCHAR(250) DEFAULT '' AFTER `email_hash`,
	ADD INDEX `email_hash_idx` (`email_hash`);

--  Changes for purging clear text email addresses (17 February 2022)

ALTER TABLE `registration`.`license`
  DROP COLUMN `email`;