/*!40101 SET NAMES utf8 */;

/*!40101 SET SQL_MODE=''*/;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
 
-- Upgrade From 2.5.x

CREATE TABLE `epaper_supps`(  
  `sp_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `sp_name` VARCHAR(255) NOT NULL,
  `sp_alias` VARCHAR(255) NOT NULL,
  `sp_order` INT(11) UNSIGNED NOT NULL,  
  `cat_id` INT(11) UNSIGNED NOT NULL,
  PRIMARY KEY (`sp_id`),
  CONSTRAINT `FK_cat_supp` FOREIGN KEY (`cat_id`) REFERENCES `epaper_categories`(`cat_id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=INNODB CHARSET=utf8;

ALTER TABLE `epaper_pages`   
  ADD COLUMN `sp_id` INT(11) UNSIGNED NOT NULL AFTER `pg_pdf`;

CREATE TABLE `epaper_bookmarks`(  
  `bkm_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `bkm_title` VARCHAR(255) NOT NULL,
  `bkm_order` INT(11) UNSIGNED NOT NULL,
  `pg_id` INT(11) UNSIGNED NOT NULL,
  `ed_id` INT(11) UNSIGNED NOT NULL,
  PRIMARY KEY (`bkm_id`),
  CONSTRAINT `FK_Bkm_Pg` FOREIGN KEY (`pg_id`) REFERENCES `epaper_pages`(`pg_id`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=INNODB CHARSET=utf8;
 

-- Upgrade from 2.6

ALTER TABLE `epaper_maps`   
  CHANGE `mp_title` `mp_title` VARCHAR(1000) CHARSET utf8 NOT NULL,
  CHANGE `mp_alias` `mp_alias` VARCHAR(1000) CHARSET utf8 NOT NULL,
  CHANGE `mp_desc` `mp_desc` TEXT CHARSET utf8 NOT NULL,
  CHANGE `mp_metakeys` `mp_metakeys` VARCHAR(1000) CHARSET utf8 NOT NULL,
  CHANGE `mp_metadesc` `mp_metadesc` VARCHAR(1000) CHARSET utf8 NOT NULL,
  CHANGE `mp_image` `mp_image` VARCHAR(255) CHARSET utf8 NOT NULL,
  CHANGE `mp_next_link` `mp_next_link` VARCHAR(255) CHARSET utf8 DEFAULT ''  NOT NULL;

ALTER TABLE `epaper_bookmarks`   
  CHANGE `bkm_title` `bkm_title` VARCHAR(255) CHARSET utf8 NOT NULL;
  

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
