USE `registration`;
CREATE TABLE `subscription_order_link` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `order_reference` varchar(50) NOT NULL,
  `sub_reference` varchar(50) NOT NULL,
  `email` varchar(100) NOT NULL,
  `license_key` varchar(30) NOT NULL,
  `is_test` tinyint(1) DEFAULT '0',
  `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `order_reference` (`order_reference`),
  KEY `sub_reference` (`sub_reference`)
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8;

--  Changes for Subscription (20 January 2022)

ALTER TABLE `registration`.`subscription_order_link`
  ADD COLUMN `email_hash` VARCHAR(100) NOT NULL DEFAULT '' AFTER `sub_reference`,
  ADD INDEX `sub_order_email` (`email_hash`);

--  Changes for Subscription (28 January 2022)

ALTER TABLE `registration`.`subscription_order_link`
  ADD COLUMN `sub_id` int(11) NOT NULL DEFAULT 0 AFTER `order_reference`,
  ADD INDEX `sub_id` (`sub_id`);

--  Changes for encrypted email (03 February 2022)

ALTER TABLE `registration`.`subscription_order_link`
  MODIFY COLUMN `email` varchar(250) NOT NULL;

--  Changes for encrypted email (15 February 2022)

ALTER TABLE `registration`.`subscription_order_link` 
	CHANGE `email` `email_enc` VARCHAR(250);

