SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

DROP TABLE IF EXISTS `package`;
DROP TABLE IF EXISTS `package_type`;

CREATE TABLE `package` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `event_id` int(11) NOT NULL,
  `package_type_id` int(11) NOT NULL,
  `package_id` varchar(20) NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text,
  `price` decimal(13,4) NOT NULL,
  `created` int(11) NOT NULL,
  `modified` int(11) NOT NULL,
  `featured` tinyint(4) NOT NULL DEFAULT '0',
  `active` tinyint(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `fk_package_package_type1_idx` (`package_type_id`),
  KEY `fk_package_event1_idx` (`event_id`),
  KEY `idx_package_id` (`package_id`),
  CONSTRAINT `fk_package_event1` FOREIGN KEY (`event_id`) REFERENCES `event` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk_package_package_type1` FOREIGN KEY (`package_type_id`) REFERENCES `package_type` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


CREATE TABLE `package_type` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(100) NOT NULL,
  `package_type_id` varchar(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_package_type_id` (`package_type_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;