

CREATE TABLE `offer` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) NOT NULL DEFAULT '',
  `is_all` tinyint(1) NOT NULL DEFAULT '0',
  `is_tier` tinyint(1) NOT NULL DEFAULT '0',
  `name` varchar(255) NOT NULL DEFAULT '',
  `image_url` varchar(255) DEFAULT NULL,
  `wallet_code` int(11) DEFAULT NULL,
  `is_free` tinyint(1) NOT NULL DEFAULT '1',
  `quantity` int(11) NOT NULL DEFAULT '0',
  `discount` float(7,2) NOT NULL DEFAULT '0.00',
  `start_date` datetime DEFAULT NULL,
  `end_date` datetime DEFAULT NULL,
  `is_expire_date` tinyint(1) NOT NULL DEFAULT '1',
  `expire_date` datetime DEFAULT NULL,
  `expire_days` int(11) DEFAULT NULL,
  `sequence` int(11) NOT NULL DEFAULT '0',
  `status` enum('PENDING','PUBLISHED','COMPLETE','DELETED') DEFAULT 'PENDING',
  `updated` datetime DEFAULT NULL,
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uuid` (`uuid`),
  KEY `uuid_2` (`uuid`)
);

CREATE TABLE `tier` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `code` int(11) NOT NULL,
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `code` (`code`)
);

INSERT INTO `tier` (`name`, `code`, `created`)
VALUES
	('VIP Team', 5, NOW()),
	('Member - No Email', 8, NOW()),
	('VIP', 9, NOW());


CREATE TABLE `tier_offer` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `tier_id` int(11) NOT NULL,
  `offer_id` int(11) NOT NULL,
  `created` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `tier_id` (`tier_id`,`offer_id`),
  KEY `tier_id_2` (`tier_id`)
);
