
DROP TABLE IF EXISTS `revision_revision`;
DROP TABLE IF EXISTS `revision_users`;
DROP TABLE IF EXISTS `revision_related`;
DROP TABLE IF EXISTS `revision_comment`;


CREATE TABLE `revision_comment` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `rid` int(11) NOT NULL,
  `uid` int(11) NOT NULL,
  `comments` varchar(255) NOT NULL,
  `create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  KEY `rid` (`rid`),
  KEY `uid` (`uid`),
  KEY `create` (`create`),
  KEY `search_fields` (`rid`,`uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `revision_related` (
  `revisionId` int(11) NOT NULL,
  `applyModule` varchar(250) NOT NULL,
  `applyObjectId` varchar(250) NOT NULL,
  `relatedModule` varchar(250) NOT NULL,
  `relatedObjectId` varchar(250) NOT NULL,
  KEY `applyModule` (`applyModule`),
  KEY `applyObjectId` (`applyObjectId`),
  KEY `relatedModule` (`relatedModule`),
  KEY `relatedObjectId` (`relatedObjectId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE `revision_revision` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user` varchar(250) NOT NULL,
  `create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `module` varchar(250) NOT NULL,
  `objectId` int(10) unsigned NOT NULL,
  `serialize` longblob NOT NULL,
  `params` longblob,
  `status` enum('Active','Inactive','ForReview') NOT NULL DEFAULT 'Inactive',
  `flag` varchar(50) DEFAULT NULL,
  `comment` varchar(150) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `module` (`module`),
  KEY `user` (`user`),
  KEY `objectId` (`objectId`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8;

CREATE TABLE `revision_users` (
  `objectId` int(11) NOT NULL,
  `module` varchar(255) COLLATE utf8_bin NOT NULL,
  `type` enum('writer','editor') COLLATE utf8_bin NOT NULL,
  `user` int(11) NOT NULL,
  KEY `module` (`module`),
  KEY `type` (`type`),
  KEY `user` (`user`),
  KEY `search_fields0` (`objectId`,`module`,`type`,`user`),
  KEY `search_fields1` (`objectId`,`module`),
  KEY `search_fields2` (`objectId`,`module`,`user`),
  KEY `search_fields3` (`objectId`,`module`,`type`),
  KEY `search_fields4` (`objectId`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
