
INSERT INTO `wap_r_type`
(`type_id`, `name`, `display_name`, `description`, `type_image`, `who_can_build`, `who_can_view`, `type_order`)
VALUES
(NULL, 'series', 'Series', 'Series of classess', '', '-1', '-1', 0),
(NULL, 'series-classes', 'Series Classes', 'List of classes added in the series', '', '-1', '-1', 0);

CREATE TABLE `was_series_class` (
  `series_class_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `series_id` int(11) UNSIGNED NOT NULL,
  `class_id` int(11) UNSIGNED NOT NULL,
  `insert_timestamp` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `update_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`series_class_id`),
  UNIQUE KEY `uqe_series_class` (`series_id`,`class_id`),
  KEY `idx_class` (`class_id`)
) ENGINE=InnoDB;

CREATE TRIGGER `was_series_class_insert_timestamp` BEFORE INSERT ON `was_series_class` FOR EACH ROW SET NEW.insert_timestamp = NOW();