--
-- Host: localhost    Database: ztest
-- ------------------------------------------------------


--
-- Table structure for table `opl_cmntRating`
--

CREATE TABLE `opl_cmntRating` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `rid` int(10) unsigned NOT NULL default '0',
  `reviewerUid` int(10) unsigned NOT NULL default '0',
  `rate` smallint(5) unsigned default '0',
  `comment` text,
  `reviewed` int(2) unsigned default '0',
  `accepted` int(2) unsigned default '0',
  `firstname` varchar(50) default NULL,
  `lastname` varchar(50) default NULL,
  `note` text,
  `cmntDate` datetime DEFAULT NULL,
  `reviewDate` datetime default NULL,
  `modDate` timestamp NOT NULL default CURRENT_TIMESTAMP,
  `deleted` tinyint(3) unsigned DEFAULT '0',
  PRIMARY KEY  (`id`),
   KEY `ind_deleted` (`deleted`)

) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `pf_bookRs`
--

CREATE TABLE `pf_bookRs` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `pfId` int(10) unsigned NOT NULL,
  `title` varchar(255) character set latin1 default NULL,
  `author` varchar(255) character set latin1 default NULL,
  `pubName` varchar(255) character set latin1 default NULL,
  `pubPlace` varchar(255) character set latin1 default NULL,
  `pubDate` varchar(50) character set latin1 default NULL,
  `callNumber` varchar(100) character set latin1 default NULL,
  `isbn` varchar(20) default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `id_2` (`id`,`pfId`),
  KEY `Index_4` USING BTREE (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `pf_record`
--

CREATE TABLE `pf_record` (
  `pfId` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(255) character set latin1 default NULL,
  `author` varchar(255) character set latin1 default NULL,
  `authPosition` varchar(255) character set latin1 default NULL,
  `introduction` text character set latin1,
  `subjectArea` varchar(255) character set latin1 default NULL,
  `createdDate` datetime default NULL,
  `expiryDate` datetime default NULL,
  `modDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`pfId`),
  UNIQUE KEY `rid` (`pfId`),
  KEY `rid_2` (`pfId`,`title`,`subjectArea`,`createdDate`,`modDate`),
  FULLTEXT KEY `Index_4` (`title`,`introduction`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `pf_sbjAreaList`
--

CREATE TABLE `pf_sbjAreaList` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `subjectArea` varchar(255) default NULL,
  UNIQUE KEY `id` (`id`),
  KEY `Index_4` USING BTREE (`subjectArea`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `pf_webRs`
--

CREATE TABLE `pf_webRs` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `pfId` int(10) unsigned NOT NULL,
  `title` varchar(255) character set latin1 default NULL,
  `author` varchar(255) character set latin1 default NULL,
  `url` varchar(255) character set latin1 default NULL,
  `description` varchar(255) character set latin1 default NULL,
  PRIMARY KEY  (`id`),
  UNIQUE KEY `id` (`id`),
  KEY `id_2` (`id`,`pfId`),
  KEY `Index_4` USING BTREE (`title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;


--
-- Host: localhost    Database: ztest
-- ------------------------------------------------------


--
-- Table structure for table `opl_subSystem`
--

CREATE TABLE `opl_subSystem` (
  `id` int(10) NOT NULL auto_increment,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `opl_subSystem`
--

INSERT INTO `opl_subSystem` VALUES (1,'Library'),(2,'Textbook'),(3,'Equipment');

--
-- Table structure for table `opl_permGroup`
--

CREATE TABLE `opl_permGroup` (
  `id` int(10) NOT NULL auto_increment,
  `ssId` int(10) NOT NULL,
  `name` varchar(255) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `opl_permGroup`
--

INSERT INTO `opl_permGroup` VALUES (1,1,'User'),(2,1,'Marc'),(3,1,'System'),(4,1,'Circ'),(5,1,'Misc'),(6,2,'User'),(7,2,'Marc'),(8,2,'System'),(9,2,'Circ'),(10,2,'Misc'),(11,3,'User'),(12,3,'Marc'),(13,3,'System'),(14,3,'Circ'),(15,3,'Misc');

--
-- Table structure for table `opl_permission`
--

CREATE TABLE `opl_permission` (
  `id` int(10) NOT NULL auto_increment,
  `grpId` int(10) NOT NULL,
  `name` varchar(255) NOT NULL,
  `code` varchar(50) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Dumping data for table `opl_permission`
--

INSERT INTO `opl_permission` VALUES (1,1,'User Add','user_add'),(2,1,'User Edit','user_edit'),(3,1,'User Delete','user_delete'),(4,2,'Marc Edit','marc_edit'),(5,3,'Pref Edit','pref_edit'),(6,4,'Circ Loan','circ_loan'),(7,4,'Circ Return','circ_return'),(8,4,'Circ Reserve','circ_rsrv'),(9,4,'Self-Reserve','circ_rsrv_self'),(10,4,'Fine','fine'),(12,4,'Notice','notice'),(13,4,'Report','report'),(14,4,'Email Bib','bibsrc'),(15,5,'Path Finder','pf'),(16,5,'Rating','rating'),(18,7,'Record Edit','tb_record_edit'),(11,4,'Payment','payment'),(19,9,'Circ Loan','tb_circ_loan'),(20,9,'Circ Return','tb_circ_return'),(21,9,'Circ Reserve','tb_circ_rsrv'),(22,9,'Self-Reserve','tb_circ_rsrv_self'),(23,9,'Fine','tb_fine'),(24,9,'Notice','tb_notice'),(25,9,'Report','tb_report'),(27,12,'Record Edit','eq_record_edit'),(28,14,'Circ Loan','eq_circ_loan'),(29,14,'Circ Return','eq_circ_return'),(30,14,'Circ Reserve','eq_circ_rsrv'),(31,14,'Self-Reserve','eq_circ_rsrv_self'),(32,14,'Report','eq_report'),(17,6,'User Add','tb_user_edit'),(26,10,'Course','tb_course_edit');


ALTER TABLE opl_user
ADD permissions text collate utf8_unicode_ci after permission;

ALTER TABLE opl_menuItem
ADD permissions varchar(255) default '' after permission;

ALTER TABLE opl_category
ADD  cattype varchar(30) collate utf8_unicode_ci NOT NULL AFTER catid, 
ADD  required enum('0','1') collate utf8_unicode_ci NOT NULL default '0',
ADD  defaultPerm text collate utf8_unicode_ci;

ALTER TABLE tb_loan
ADD  teacherName varchar(255) default NULL,
ADD  courseName varchar(255) default NULL;


ALTER TABLE tb_items 
CHANGE price price varchar(50) default NULL;

insert into eq_fieldDataType set id=6,dataType='GradeLevel';

