-- #############################################################################
-- Union circulation data
-- script/util/updateZDB: 
--      - specify if the site provides circulation data, or
-- script/util/updatePref: update union URL and turn on/off circulation update.
-- #alter table opl_zDatabase
-- #    add circData tinyint(1) unsigned not null default 0;
-- #insert into opl_preference 
-- #    (var, val, opt, description, hidden, gid, gOrder)
-- #    values 
-- #    ('unionCircUpdate','0','0|1','1:enable auto update circulation data to union; 0:disabled ',0,8,5), 
-- #    ('unionCircUpdateDate','0000-00-00 00:00:00','datetime','date and time in international format (YYYY-mm-dd HH:MM:SS)',1,8,6);

-- #############################################################################
-- Student ILL for branch version
-- script/util/updateZDB: 
--      - tuen of/off student ILL
--      - update location ID
-- #alter table opl_zDatabase 
-- #    add studentILL tinyint(1) unsigned not null default 0,
-- #    add locationId varchar(50);

-- #DROP TABLE IF EXISTS `opl_studentILL`;
-- #CREATE TABLE `opl_studentILL` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `uid` int(10) unsigned NOT NULL default '0',
-- #  `zid` tinyint(3) unsigned NOT NULL default '0',
-- #  `rid` int(10) unsigned default NULL,
-- #  `title` text,
-- #  `author` text,
-- #  `pubDate` varchar(20) NOT NULL default '',
-- #  `description` text,
-- #  `dRequest` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `dExpiry` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `dApproval` datetime default NULL,
-- #  `dRejection` datetime default NULL,
-- #  `responderList` varchar(255) NOT NULL default '',
-- #  `illAdmin` int(10) unsigned NOT NULL default '0',
-- #  `illID` int(10) unsigned NOT NULL default '0',
-- #  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-- #  PRIMARY KEY  (`id`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- #insert into opl_permission 
-- #    (grpId,name,code) 
-- #    values 
-- #    (4,'ILL Filter','circ_ill_filter');
-- #insert into opl_menuItem 
-- #    (PARENT_ID,orderValue,language,title,path,permission,permissions) 
-- #    values 
-- #    (12,3,'en','Student ILL Request List','/bin/ill/list','','');
-- #update opl_user set permissions=concat_ws(',', permissions, 'circ_ill_filter') where uid=1;

-- #############################################################################
-- Auto-merge
-- script/update/20100518_addRecordIdentifier: generate record identifier database for existing site.
-- #DROP TABLE IF EXISTS `opl_recordIdentifier`;
-- #CREATE TABLE `opl_recordIdentifier` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `rid` int(10) unsigned NOT NULL default '1',
-- #  `tag` char(3) NOT NULL default '',
-- #  `code` char(1) NOT NULL default '',
-- #  `data` varchar(255) NOT NULL default '',
-- #  PRIMARY KEY  (`id`),
-- #  KEY `i_tcd` (`tag`,`code`,`data`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- #alter table opl_marcImport
-- #    change cMerge mode enum('autoMerge','overlay','manualMerge','new') NOT NULL default 'autoMerge',
-- #    add mergeMode enum('strict','loose') not null default 'strict' after mode,
-- #    add countMergedHolding int(10) unsigned default '0' after countMerged,
-- #    add holding_op enum('update','preserve') NOT NULL default 'update',
-- #    add recordSource enum('generic','OCoLC') NOT NULL default 'generic';

-- #############################################################################

-- #--
-- #-- Table structure for table `eq_odl`
-- #--
-- #
-- #CREATE TABLE IF NOT EXISTS `eq_odl` (
-- #  `odl_id` int(10) unsigned NOT NULL auto_increment,
-- #  `idloan` int(10) unsigned default '0',
-- #  `type` set('overdue','lost','damaged') default 'overdue',
-- #  `days_overdue` tinyint(3) unsigned default '0',
-- #  `ondate` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `settleDate` datetime default NULL,
-- #  PRIMARY KEY  (`odl_id`),
-- #  KEY `NewIndex` (`odl_id`,`idloan`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- #
-- #--
-- #-- Table structure for table `opl_bookingFor`
-- #--
-- #
-- #CREATE TABLE IF NOT EXISTS `opl_bookingFor` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `bookingId` int(10) NOT NULL default '0',
-- #  `uid` int(10) unsigned NOT NULL default '0',
-- #  `notes` varchar(150) default '',
-- #  `deleted` tinyint(3) unsigned default '0',
-- #  `createdDate` datetime default NULL,
-- #  `modDate` timestamp NOT NULL default CURRENT_TIMESTAMP,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `std_id` (`uid`),
-- #  KEY `bookingId` (`bookingId`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- #
-- #--
-- #-- Table structure for table `opl_bookingHold`
-- #--
-- #
-- #CREATE TABLE IF NOT EXISTS `opl_bookingHold` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `bookingId` int(10) unsigned NOT NULL,
-- #  `barcode` varchar(50) default '',
-- #  `rid` int(10) unsigned NOT NULL,
-- #  `itemCategory` tinyint(3) unsigned NOT NULL default '1',
-- #  `notes` varchar(150) default '',
-- #  `holdDate` datetime default NULL,
-- #  `idloan` int(10) unsigned NOT NULL default '0',
-- #  `modDate` timestamp NOT NULL default CURRENT_TIMESTAMP,
-- #  `deleted` tinyint(3) unsigned default '0',
-- #  PRIMARY KEY  (`id`),
-- #  KEY `bookingId` (`bookingId`),
-- #  KEY `barcode` (`barcode`),
-- #  KEY `idloan` (`idloan`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- #
-- #--
-- #-- Table structure for table `opl_bookingItem`
-- #--
-- #
-- #CREATE TABLE IF NOT EXISTS `opl_bookingItem` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `bookingId` int(10) NOT NULL default '0',
-- #  `idReserve` int(10) unsigned default NULL,
-- #  `rid` int(10) unsigned NOT NULL default '0',
-- #  `itemCategory` tinyint(3) unsigned default '1',
-- #  `numOfCopy` int(10) unsigned NOT NULL default '0',
-- #  `notes` varchar(150) default '',
-- #  `deleted` tinyint(3) unsigned default '0',
-- #  `createdDate` datetime default NULL,
-- #  `modDate` datetime default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `bookingId` (`bookingId`),
-- #  KEY `itemCategory` (`itemCategory`),
-- #  KEY `idReserve` (`idReserve`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
-- #
-- #--
-- #-- Table structure for table `opl_bookingRequest`
-- #--
-- #
-- #CREATE TABLE IF NOT EXISTS `opl_bookingRequest` (
-- #  `bookingId` int(10) NOT NULL auto_increment,
-- #  `responsible` int(10) unsigned default NULL,
-- #  `achv_id` int(10) unsigned default '0',
-- #  `reqUid` int(10) unsigned default '0',
-- #  `reqFirstname` varchar(150) default NULL,
-- #  `reqLastname` varchar(150) default NULL,
-- #  `department` varchar(150) default NULL,
-- #  `course` varchar(150) default NULL,
-- #  `section` varchar(150) default NULL,
-- #  `reserveFrom` datetime default NULL,
-- #  `reserveTo` datetime default NULL,
-- #  `status` enum('waiting','processing','ready','cancel','filled') default 'waiting',
-- #  `notes` varchar(150) default '',
-- #  `deleted` tinyint(3) unsigned default '0',
-- #  `createdDate` datetime default NULL,
-- #  `modDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-- #  PRIMARY KEY  (`bookingId`),
-- #  KEY `requestorId` (`reqUid`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- #alter table opl_fineRate
-- #    change overDue overdue float(10,2) default '0.00',
-- #    add overduePerHour float(10,2) default '0.00' after overdue,
-- #    add itemCategory enum('1','2','3') NOT NULL default '1';

-- #alter table opl_hold add idloan int(10) unsigned default '0' after idReserve;

-- #drop index location_ind on opl_item;
-- #create index ind_location on opl_item (location);
-- #create index callNumber on opl_item (callNumber);

-- #alter table opl_itemType 
-- #    drop primary key, 
-- #    add primary key (id,itemCategory);

-- alter table opl_marcImport
--     change cMerge mode enum('autoMerge','overlay','manualMerge','new') NOT NULL default 'autoMerge',
--     add mergeMode enum('strict','loose') not null default 'strict' after mode,
--     add countMergedHolding int(10) unsigned default '0' after countMerged,
--     add holding_op enum('update','preserve') NOT NULL default 'update',
--     add recordSource enum('generic','OCoLC') NOT NULL default 'generic';

-- #alter table opl_menuItem change permissions permissions varchar(255) default '';

--
-- Table structure for table `opl_nystd`
--

-- #CREATE TABLE IF NOT EXISTS `opl_nystd` (
-- #  `NY_ID` varchar(20) default NULL,
-- #  `grade` varchar(5) default NULL,
-- #  `level` varchar(50) default NULL,
-- #  `category` varchar(150) default NULL,
-- #  `subject` varchar(150) default NULL,
-- #  `NY_Std_No` int(3) unsigned default '0',
-- #  `NY_Bmrk_No` int(3) unsigned default '0',
-- #  `NYStandard` text,
-- #  `NYBmrk` text,
-- #  `subjectStandard` varchar(254) default NULL,
-- #  `cerfcode` text,
-- #  `subjectAlphabet` char(1) default NULL,
-- #  FULLTEXT KEY `NYstandard` (`NYStandard`,`subjectStandard`,`NYBmrk`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- #alter table opl_odl add hours_overdue tinyint(3) unsigned default '0' after days_overdue;

--
-- Table structure for table `opl_payRefundInfo`
--

-- #CREATE TABLE IF NOT EXISTS `opl_payRefundInfo` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `tid` int(10) unsigned default NULL,
-- #  `paid_tid` int(10) unsigned default NULL,
-- #  `note` varchar(60) default NULL,
-- #  `date` datetime default '0000-00-00 00:00:00',
-- #  PRIMARY KEY  (`id`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- insert into opl_preference values 
--     ('unionCircUpdate','0','0|1','1:enable auto update circulation data to union; 0:disabled ',0,8,5), 
--     ('unionCircUpdateDate','0000-00-00 00:00:00','datetime','date and time in international format (YYYY-mm-dd HH:MM:SS)',0,8,6);

-- #--
-- #-- Table structure for table `opl_prefFormParam`
-- #--
-- #
-- #CREATE TABLE IF NOT EXISTS `opl_prefFormParam` (
-- #  `var` varchar(150) NOT NULL,
-- #  `listOrder` tinyint(2) unsigned default '0',
-- #  `name` varchar(150) NOT NULL,
-- #  `val` varchar(150) NOT NULL,
-- #  KEY `var` (`var`,`val`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- #alter table opl_preference
-- #    CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci,
-- #    add valShow text after val,
-- #    add varType set('text','radio','checkbox','select','multipleSelect','timeLength') default 'text' after opt;
-- #insert into opl_preference
-- #    (var, val, valShow, opt, varType, description, hidden, gid, gOrder)
-- #    values
-- #    ('timezone','America/Montreal','(GMT -5.0) Eastern Time (US &amp; Canada), Bogota, Lima',NULL,'select ','Time Zone',0,1,9);
-- #update opl_preference set varType='text' where var in (
-- #    'amazonId',
-- #    'amazonSecreteKey',
-- #    'cerf',
-- #    'country',
-- #    'dateFirst',
-- #    'dateLast',
-- #    'dateProfile',
-- #    'defCategory',
-- #    'emailAddress',
-- #    'emailPass',
-- #    'emailSmtp',
-- #    'emailUser',
-- #    'fdrtax',
-- #    'iumap',
-- #    'iuset',
-- #    'libAddress',
-- #    'libCity',
-- #    'libcode',
-- #    'libEmail',
-- #    'libFax',
-- #    'libname',
-- #    'libPhone',
-- #    'libState',
-- #    'libZip',
-- #    'link1_name',
-- #    'link1_url',
-- #    'link2_name',
-- #    'link2_url',
-- #    'lockingDatetime',
-- #    'logo',
-- #    'overwrittenByBarcode',
-- #    'OWLsrchLocation',
-- #    'prvtax',
-- #    'recordLock',
-- #    'reportGroup',
-- #    'searchAdv',
-- #    'slogan',
-- #    'syndeticsId',
-- #    'theme',
-- #    'union852',
-- #    'unionCircUpdateDate',
-- #    'unionId',
-- #    'unionSvcUrl',
-- #    'useAttOrder',
-- #    'warningDatetime',
-- #    'workdayFirst',
-- #    'workdayLast');
-- #update opl_preference set varType='radio' where var in (
-- #    'autoAdd2NewItemList',
-- #    'autoUpdateUnion',
-- #    'charge_damage',
-- #    'charge_lost',
-- #    'charge_overdue',
-- #    'circulationSound',
-- #    'equipmentMgmnt',
-- #    'fine',
-- #    'multilingual',
-- #    'patronItemPrivacy',
-- #    'showARL',
-- #    'showLocation',
-- #    'showPathfinder',
-- #    'textbookChargeDamage',
-- #    'textbookChargeLost',
-- #    'textbookChargeOverdue',
-- #    'textbookFine',
-- #    'textbookMgmnt',
-- #    'unionCircUpdate',
-- #    'useHolidays',
-- #    'validateBarcode');
-- #update opl_preference set varType='checkbox' where var in (
-- #    'OWLBgSrchFields');
-- #update opl_preference set varType='select' where var in (
-- #    'allowOverdue',
-- #    'barcodeType',
-- #    'bibformat',
-- #    'defaultSearchPage',
-- #    'lang',
-- #    'rating',
-- #    'showBeginnerSrch',
-- #    'timezone');
-- #update opl_preference set varType='timeLength' where var in (
-- #    'bibTimeclear',
-- #    'timeclear',
-- #    'timeout');
-- #update opl_preference set valShow=val;
-- #update opl_preference pref inner join opl_prefFormParam param using (var) 
-- #    set valShow = param.name
-- #    where pref.varType in ('radio','select')
-- #        && pref.val = param.val;

--
-- Table structure for table `opl_recordIdentifier`
--

-- DROP TABLE IF EXISTS `opl_recordIdentifier`;
-- CREATE TABLE `opl_recordIdentifier` (
--   `id` int(10) unsigned NOT NULL auto_increment,
--   `rid` int(10) unsigned NOT NULL default '1',
--   `tag` char(3) NOT NULL default '',
--   `code` char(1) NOT NULL default '',
--   `data` varchar(255) NOT NULL default '',
--   PRIMARY KEY  (`id`),
--   KEY `i_tcd` (`tag`,`code`,`data`)
-- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `opl_studentILL`
--

-- DROP TABLE IF EXISTS `opl_studentILL`;
-- CREATE TABLE `opl_studentILL` (
--   `id` int(10) unsigned NOT NULL auto_increment,
--   `uid` int(10) unsigned NOT NULL default '0',
--   `zid` tinyint(3) unsigned NOT NULL default '0',
--   `rid` int(10) unsigned default NULL,
--   `title` text,
--   `author` text,
--   `pubDate` varchar(20) NOT NULL default '',
--   `description` text,
--   `dRequest` datetime NOT NULL default '0000-00-00 00:00:00',
--   `dExpiry` datetime NOT NULL default '0000-00-00 00:00:00',
--   `dApproval` datetime default NULL,
--   `dRejection` datetime default NULL,
--   `responderList` varchar(255) NOT NULL default '',
--   `illAdmin` int(10) unsigned NOT NULL default '0',
--   `illID` int(10) unsigned NOT NULL default '0',
--   `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
--   PRIMARY KEY  (`id`)
-- ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `opl_teacherSchedule`
--

-- #CREATE TABLE IF NOT EXISTS `opl_teacherSchedule` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `sectionId` varchar(45) default NULL,
-- #  `courseId` int(8) unsigned default NULL,
-- #  `courseCode` varchar(45) default NULL,
-- #  `teacherId` varchar(45) default NULL,
-- #  `createdDate` datetime default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `Index_2` (`sectionId`,`courseCode`,`teacherId`,`courseId`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- #alter table opl_transactiondetail
-- #    add hourlyRate float(10,2) default '0.00' after rate,
-- #    add overdueHours tinyint(3) unsigned default '0' after overdueDays;

-- alter table opl_transactions add code smallint(6) default NULL after tid;
-- #alter table opl_transactions 
-- #    change amount amount float(10,2) NOT NULL default '0.00',
-- #    change date date datetime NOT NULL default '0000-00-00 00:00:00';
-- #drop index tid_2 on opl_transactions;
-- #create index tid_2 on opl_transactions (tid,uid,date,code);

-- alter table opl_zDatabase 
--     add circData tinyint(3) unsigned NOT NULL default '0',
--     add studentILL tinyint(3) unsigned NOT NULL default '0',
--     add locationId varchar(50) default NULL;

-- #alter table pf_bookRs add rid int(10) unsigned NOT NULL default '0' after id;
-- #alter table pf_webRs change description description text;

-- #alter table tb_courseList 
-- #    drop index Index_2, 
-- #    add index Index_2 (`courseCode`,`courseName`,`grade`,`level`,`schoolYear`);

--
-- Table structure for table `tb_csvDuplicate`
--

-- #CREATE TABLE IF NOT EXISTS `tb_csvDuplicate` (
-- #  `mid` int(10) NOT NULL auto_increment,
-- #  `iid` int(10) unsigned NOT NULL default '0',
-- #  `content` mediumtext NOT NULL,
-- #  PRIMARY KEY  (`mid`),
-- #  KEY `i_iid` (`iid`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tb_csvImport`
--

-- #CREATE TABLE IF NOT EXISTS `tb_csvImport` (
-- #  `iid` int(10) unsigned NOT NULL auto_increment,
-- #  `sid` int(10) unsigned default '0',
-- #  `lid` int(10) unsigned default '0',
-- #  `uid` int(10) unsigned NOT NULL default '0',
-- #  `sCode` varchar(50) default NULL,
-- #  `lCode` varchar(50) default NULL,
-- #  `itemType` varchar(50) default NULL,
-- #  `filename` varchar(255) default NULL,
-- #  `data` mediumtext,
-- #  `header` mediumtext,
-- #  `mapHeader` mediumtext,
-- #  `dataDup` mediumtext,
-- #  `cMerge` tinyint(1) unsigned default '1',
-- #  `countImported` int(10) unsigned default '0',
-- #  `countMerged` int(10) unsigned default '0',
-- #  `countProcessed` int(10) unsigned default '0',
-- #  `countTotal` int(10) unsigned NOT NULL default '0',
-- #  `countTotalHolding` int(10) default NULL,
-- #  `dateImport` datetime default NULL,
-- #  `dateUpload` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `mesgDigest` varchar(128) default NULL,
-- #  `status` enum('uploaded','rejected','processed','accepted','done') default NULL,
-- #  `addToNewitemList` tinyint(1) unsigned default '0',
-- #  `newItemExpDate` datetime default NULL,
-- #  PRIMARY KEY  (`iid`),
-- #  KEY `i_uid` (`uid`),
-- #  KEY `i_lid` (`lid`),
-- #  KEY `i_msgDigest` (`mesgDigest`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tb_hold`
--

-- #CREATE TABLE IF NOT EXISTS `tb_hold` (
-- #  `id` int(10) NOT NULL auto_increment,
-- #  `idReserve` int(10) unsigned NOT NULL default '0',
-- #  `barcode` varchar(50) NOT NULL default '',
-- #  `dateHold` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `dateExpiry` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `dateLoan` datetime default NULL,
-- #  `dateCancel` datetime default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `i_hold` (`idReserve`,`barcode`,`dateLoan`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- #create index i_fId on tb_index_map (fId);

-- #alter table tb_items 
-- #    change acquisitionDate acquisitionDate date default NULL,
-- #    add budgetCategory varchar(255) default NULL after buildingCode,
-- #    add vendorCatalogNumber varchar(255) default NULL after deleted;
-- #create index r_index1 on tb_items (rid,modDate,importDate,available);

--
-- Table structure for table `tb_marcDuplicate`
--

-- #CREATE TABLE IF NOT EXISTS `tb_marcDuplicate` (
-- #  `mid` int(10) unsigned NOT NULL auto_increment,
-- #  `iid` int(10) unsigned NOT NULL default '0',
-- #  `content` mediumtext,
-- #  PRIMARY KEY  (`mid`),
-- #  KEY `i_iid` (`iid`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tb_marcImport`
--

-- #CREATE TABLE IF NOT EXISTS `tb_marcImport` (
-- #  `iid` int(10) unsigned NOT NULL auto_increment,
-- #  `sid` int(10) unsigned default '0',
-- #  `lid` int(10) unsigned default '0',
-- #  `uid` int(10) unsigned NOT NULL default '0',
-- #  `encoding` enum('UTF-8','MARC-8') NOT NULL default 'UTF-8',
-- #  `sCode` varchar(50) default NULL,
-- #  `lCode` varchar(50) default NULL,
-- #  `itemType` varchar(50) default NULL,
-- #  `cMerge` tinyint(1) unsigned default '1',
-- #  `countImported` int(10) unsigned default '0',
-- #  `countMerged` int(10) unsigned default '0',
-- #  `countProcessed` int(10) unsigned default '0',
-- #  `countTotal` int(10) unsigned NOT NULL default '0',
-- #  `dateImport` datetime default NULL,
-- #  `dateUpload` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `mesgDigest` varchar(128) default '',
-- #  `status` enum('uploaded','rejected','accepted','indexing','done') NOT NULL default 'uploaded',
-- #  `addToNewitemList` tinyint(1) unsigned default '0',
-- #  `newItemExpDate` datetime default NULL,
-- #  PRIMARY KEY  (`iid`),
-- #  KEY `i_uid` (`uid`),
-- #  KEY `i_lid` (`lid`),
-- #  KEY `i_mesgDigest` (`mesgDigest`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tb_odl`
--

-- #CREATE TABLE IF NOT EXISTS `tb_odl` (
-- #  `odl_id` int(10) unsigned NOT NULL auto_increment,
-- #  `idloan` int(10) unsigned default '0',
-- #  `type` set('overdue','lost','damaged') default 'overdue',
-- #  `days_overdue` tinyint(3) unsigned default '0',
-- #  `ondate` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `settleDate` datetime default NULL,
-- #  PRIMARY KEY  (`odl_id`),
-- #  KEY `NewIndex` (`odl_id`,`idloan`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- #alter table tb_records
-- #    add updating enum('0','1') NOT NULL default '0' after fVal;

--
-- Table structure for table `tb_reserve`
--

-- #CREATE TABLE IF NOT EXISTS `tb_reserve` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `rid` int(10) unsigned NOT NULL default '0',
-- #  `uid` int(10) unsigned NOT NULL default '0',
-- #  `numCopyReserve` tinyint(4) default '1',
-- #  `dateReserve` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `dateExpiry` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `dateCancel` datetime default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `i_reserve` (`rid`,`uid`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tb_transactiondetail`
--

-- #CREATE TABLE IF NOT EXISTS `tb_transactiondetail` (
-- #  `tid` int(10) NOT NULL,
-- #  `odl_id` int(10) unsigned NOT NULL default '0',
-- #  `responsible` varchar(64) default '',
-- #  `materials` set('book','video','DVD','reserve material') default 'book',
-- #  `rate` float(10,2) default '0.00',
-- #  `overdueDays` tinyint(3) unsigned default '0',
-- #  `fineAmount` float(10,2) default '0.00',
-- #  `forgivenAmount` float(10,2) default '0.00',
-- #  `amount` float(10,2) default '0.00',
-- #  `taxes` float(10,2) default '0.00',
-- #  `note` varchar(254) default '',
-- #  PRIMARY KEY  (`tid`),
-- #  KEY `NewIndex` (`tid`,`odl_id`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tb_transactions`
--

-- #CREATE TABLE IF NOT EXISTS `tb_transactions` (
-- #  `tid` int(10) unsigned NOT NULL auto_increment,
-- #  `ptid` int(10) unsigned NOT NULL default '0',
-- #  `code` smallint(6) default NULL,
-- #  `uid` int(10) unsigned NOT NULL default '0',
-- #  `amount` float(10,2) default '0.00',
-- #  `balance` float(10,2) NOT NULL default '0.00',
-- #  `date` datetime default '0000-00-00 00:00:00',
-- #  `description` varchar(50) default NULL,
-- #  `settleDate` datetime default NULL,
-- #  PRIMARY KEY  (`tid`),
-- #  UNIQUE KEY `tid` (`tid`),
-- #  KEY `tid_2` (`tid`,`uid`,`date`,`code`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_bookDistribution`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_bookDistribution` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `pid` int(10) unsigned default NULL,
-- #  `teacherId` varchar(45) default NULL,
-- #  `studentId` varchar(45) default NULL,
-- #  `source` varchar(45) default NULL COMMENT 'receive source',
-- #  `courseId` int(10) unsigned default NULL,
-- #  `sectionId` varchar(45) default NULL,
-- #  `ISBN` varchar(45) NOT NULL,
-- #  `barcode` varchar(45) default NULL,
-- #  `distDate` datetime NOT NULL,
-- #  `returnBy` set('teacher','student') default 'teacher',
-- #  `returnDate` datetime default NULL,
-- #  `returnStatus` enum('ok','lost','damaged','found') NOT NULL default 'ok',
-- #  `schoolYearId` int(10) unsigned NOT NULL,
-- #  PRIMARY KEY  (`id`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `tbk_courseBookAssignment`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_courseBookAssignment` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `courseId` int(10) unsigned default NULL,
-- #  `courseCode` varchar(45) NOT NULL,
-- #  `ISBN` varchar(150) NOT NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `Index_2` (`courseCode`,`ISBN`,`courseId`,`id`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_courseList`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_courseList` (
-- #  `courseId` int(10) unsigned NOT NULL auto_increment,
-- #  `courseCode` varchar(45) NOT NULL,
-- #  `courseName` varchar(150) default NULL,
-- #  `descriptions` text,
-- #  `grade` varchar(45) default NULL,
-- #  `schoolYear` varchar(45) default NULL,
-- #  `level` varchar(45) default NULL,
-- #  `instructionHours` varchar(45) default NULL,
-- #  `prerequisite` varchar(45) default NULL,
-- #  PRIMARY KEY  (`courseId`),
-- #  KEY `Index_2` (`courseCode`,`courseName`,`grade`,`level`,`schoolYear`),
-- #  FULLTEXT KEY `Index_3` (`courseName`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `tbk_courseSection`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_courseSection` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `sectionId` varchar(45) NOT NULL,
-- #  `courseId` int(10) unsigned default NULL,
-- #  `courseCode` varchar(45) NOT NULL,
-- #  `hour` varchar(45) default NULL,
-- #  `location` varchar(45) default NULL,
-- #  `notes` text,
-- #  `building` varchar(45) default NULL,
-- #  `homeroom` varchar(45) default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `Index_2` (`sectionId`,`courseCode`,`building`,`homeroom`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `tbk_items`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_items` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `rid` int(11) default NULL,
-- #  `barcode` varchar(45) default NULL,
-- #  `ISBN` varchar(45) default NULL,
-- #  `status` enum('ok','lost','damaged','found') default 'ok',
-- #  `colectedDate` datetime default NULL,
-- #  `modifiedDate` datetime default NULL,
-- #  `price` varchar(45) default NULL,
-- #  PRIMARY KEY  (`id`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `tbk_marcIn`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_marcIn` (
-- #  `iid` int(10) unsigned NOT NULL auto_increment,
-- #  `uid` int(10) unsigned NOT NULL default '0',
-- #  `encoding` enum('UTF-8','MARC-8') NOT NULL default 'UTF-8',
-- #  `iImported` int(10) unsigned default '0',
-- #  `iProcessed` int(10) unsigned default '0',
-- #  `iTotal` int(10) unsigned NOT NULL default '0',
-- #  `importDate` datetime default NULL,
-- #  `uploadDate` datetime NOT NULL default '0000-00-00 00:00:00',
-- #  `mesgDigest` varchar(128) default '',
-- #  `status` enum('uploaded','rejected','accepted','done') NOT NULL default 'uploaded',
-- #  PRIMARY KEY  (`iid`),
-- #  KEY `i_uid` (`uid`),
-- #  KEY `i_mesgDigest` (`mesgDigest`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_marcRecord`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_marcRecord` (
-- #  `rid` int(10) NOT NULL auto_increment,
-- #  `title` text,
-- #  `title_sort` varchar(255) default NULL,
-- #  `callNumMin` varchar(50) default NULL,
-- #  `callNumMax` varchar(50) default NULL,
-- #  `author` text,
-- #  `pubPlace` varchar(60) default NULL,
-- #  `pubName` varchar(60) default NULL,
-- #  `pubDate` varchar(20) default NULL,
-- #  `lockExpire` datetime default NULL,
-- #  `editUid` int(10) unsigned default NULL,
-- #  `sessionid` varchar(40) default NULL,
-- #  `modDate` datetime default '0000-00-00 00:00:00',
-- #  `xml` text NOT NULL,
-- #  `ISBN` varchar(45) default NULL,
-- #  PRIMARY KEY  (`rid`),
-- #  KEY `index1` USING BTREE (`modDate`),
-- #  KEY `Index_3` (`ISBN`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_preference`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_preference` (
-- #  `var` varchar(25) NOT NULL default '',
-- #  `val` text,
-- #  `opt` varchar(10) default NULL,
-- #  `description` text,
-- #  `hidden` tinyint(3) unsigned default '0'
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_preparation`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_preparation` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `type` enum('teacher','student','course','homeroom','request') NOT NULL,
-- #  `expectedReadiness` date default NULL,
-- #  `expiryDate` date default NULL,
-- #  `preparedDate` date NOT NULL,
-- #  `preparedBy` varchar(255) NOT NULL,
-- #  `schoolYearId` int(10) unsigned NOT NULL,
-- #  PRIMARY KEY  (`id`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `tbk_preparationDetails`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_preparationDetails` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `pid` int(10) unsigned NOT NULL,
-- #  `ISBN` varchar(20) default NULL,
-- #  `courseId` int(10) unsigned default NULL,
-- #  `sectionId` varchar(45) default NULL,
-- #  `teacherId` varchar(45) default NULL,
-- #  `studentId` varchar(45) default NULL,
-- #  `homeroom` varchar(45) default NULL,
-- #  `nStudents` int(10) unsigned default NULL,
-- #  `allocationType` enum('perStudent','perClass','perSection') default NULL,
-- #  `nCopiesPerAllocation` int(10) unsigned default NULL,
-- #  `total` int(10) unsigned default '0',
-- #  `nDistributed` int(10) unsigned default '0',
-- #  `recipient` enum('teacher','student') NOT NULL,
-- #  PRIMARY KEY  (`id`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `tbk_recordindex`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_recordindex` (
-- #  `rid` int(10) unsigned NOT NULL,
-- #  `attr_1003` text,
-- #  `attr_1018` text,
-- #  `attr_12` text,
-- #  `attr_13` text,
-- #  `attr_16` text,
-- #  `attr_21` text,
-- #  `attr_31` text,
-- #  `attr_4` text,
-- #  `attr_5` text,
-- #  `attr_5000` text,
-- #  `attr_5001` text,
-- #  `attr_5002` text,
-- #  `attr_59` text,
-- #  `attr_6` text,
-- #  `attr_63` text,
-- #  `attr_7` text,
-- #  `attr_8` text,
-- #  `attr_9` text,
-- #  `attr_s1003` text,
-- #  `attr_s31` text,
-- #  `attr_s4` text,
-- #  `attr_s5001` text,
-- #  PRIMARY KEY  (`rid`),
-- #  FULLTEXT KEY `index_a1003` (`attr_1003`),
-- #  FULLTEXT KEY `index_a1016` (`attr_4`,`attr_5`,`attr_6`,`attr_21`,`attr_31`,`attr_59`,`attr_63`,`attr_1003`),
-- #  FULLTEXT KEY `index_a1018` (`attr_1018`),
-- #  FULLTEXT KEY `index_a12` (`attr_12`),
-- #  FULLTEXT KEY `index_a13` (`attr_13`),
-- #  FULLTEXT KEY `index_a16` (`attr_16`),
-- #  FULLTEXT KEY `index_a21` (`attr_21`),
-- #  FULLTEXT KEY `index_a31` (`attr_31`),
-- #  FULLTEXT KEY `index_a4` (`attr_4`),
-- #  FULLTEXT KEY `index_a5` (`attr_5`),
-- #  FULLTEXT KEY `index_a5000` (`attr_5000`),
-- #  FULLTEXT KEY `index_a5001` (`attr_5001`),
-- #  FULLTEXT KEY `index_a5002` (`attr_5002`),
-- #  FULLTEXT KEY `index_a59` (`attr_59`),
-- #  FULLTEXT KEY `index_a6` (`attr_6`),
-- #  FULLTEXT KEY `index_a63` (`attr_63`),
-- #  FULLTEXT KEY `index_a7` (`attr_7`),
-- #  FULLTEXT KEY `index_a8` (`attr_8`),
-- #  FULLTEXT KEY `index_a9` (`attr_9`),
-- #  FULLTEXT KEY `index_as1003` (`attr_s1003`),
-- #  FULLTEXT KEY `index_as31` (`attr_s31`),
-- #  FULLTEXT KEY `index_as4` (`attr_s4`),
-- #  FULLTEXT KEY `index_as5001` (`attr_s5001`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_request`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_request` (
-- #  `reqId` int(10) unsigned NOT NULL auto_increment,
-- #  `teacherId` varchar(45) default NULL,
-- #  `courseCode` varchar(45) default NULL,
-- #  `sectionId` varchar(45) default NULL,
-- #  `quantity` int(3) default NULL,
-- #  `requestDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-- #  `status` set('completed','waiting','processing','cancel') default NULL,
-- #  PRIMARY KEY  (`reqId`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_requestProcess`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_requestProcess` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `reqId` int(11) NOT NULL,
-- #  `qty` int(11) NOT NULL,
-- #  `notes` text NOT NULL,
-- #  `processDate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
-- #  PRIMARY KEY  (`id`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_schoolYear`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_schoolYear` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `schoolYear` varchar(45) NOT NULL,
-- #  `firstDate` datetime default NULL,
-- #  `lastDate` datetime default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `Index_2` (`firstDate`,`lastDate`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_studentSchedule`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_studentSchedule` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `sectionId` varchar(45) NOT NULL,
-- #  `studentId` varchar(45) NOT NULL,
-- #  `courseId` int(10) unsigned default NULL,
-- #  `courseCode` varchar(45) NOT NULL,
-- #  `notes` text,
-- #  `created` timestamp NOT NULL default CURRENT_TIMESTAMP,
-- #  `importId` int(11) default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `Index_2` (`sectionId`,`studentId`,`courseCode`,`courseId`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `tbk_students`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_students` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `studentId` varchar(18) default NULL,
-- #  `lastName` varchar(45) default NULL,
-- #  `firstName` varchar(45) default NULL,
-- #  `addrLine1` varchar(150) default NULL,
-- #  `addrLine2` varchar(150) default NULL,
-- #  `city` varchar(45) default NULL,
-- #  `state` varchar(25) default NULL,
-- #  `zip` varchar(25) default NULL,
-- #  `country` varchar(25) default 'USA',
-- #  `grade` varchar(25) default NULL,
-- #  `homeroom` varchar(150) default NULL,
-- #  `phone` varchar(45) default NULL,
-- #  `userBarcode` varchar(18) default NULL,
-- #  `created` datetime default NULL,
-- #  `importId` int(11) default NULL,
-- #  `email` varchar(255) default NULL,
-- #  `birthday` datetime default NULL,
-- #  `gender` tinyint(1) default NULL,
-- #  `status` tinyint(1) default NULL,
-- #  `notes` text,
-- #  `yearGraduation` smallint(5) default '0',
-- #  `building` varchar(45) default NULL,
-- #  `teacher` varchar(45) default NULL,
-- #  `fax` varchar(45) default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `Index_2` (`studentId`,`lastName`,`firstName`,`userBarcode`,`building`,`teacher`,`homeroom`,`grade`),
-- #  FULLTEXT KEY `Index_3` (`lastName`,`firstName`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;

--
-- Table structure for table `tbk_teacherSchedule`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_teacherSchedule` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `sectionId` varchar(45) default NULL,
-- #  `courseId` int(8) unsigned default NULL,
-- #  `courseCode` varchar(45) default NULL,
-- #  `teacherId` varchar(45) default NULL,
-- #  `createdDate` datetime default NULL,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `Index_2` (`sectionId`,`courseCode`,`teacherId`,`courseId`)
-- #) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--
-- Table structure for table `tbk_teachers`
--

-- #CREATE TABLE IF NOT EXISTS `tbk_teachers` (
-- #  `id` int(10) unsigned NOT NULL auto_increment,
-- #  `teacherId` varchar(45) NOT NULL,
-- #  `lastName` varchar(45) default NULL,
-- #  `firstName` varchar(45) default NULL,
-- #  `addrLine1` varchar(150) default NULL,
-- #  `addrLine2` varchar(150) default NULL,
-- #  `city` varchar(45) default NULL,
-- #  `state` varchar(45) default NULL,
-- #  `zip` varchar(25) default NULL,
-- #  `phone` varchar(45) default NULL,
-- #  `country` varchar(45) default 'USA',
-- #  `email` varchar(150) default NULL,
-- #  `birthday` date default NULL,
-- #  `importId` int(11) default NULL,
-- #  `gender` tinyint(1) default NULL,
-- #  `status` tinyint(1) default NULL,
-- #  `notes` text,
-- #  `created` timestamp NOT NULL default CURRENT_TIMESTAMP,
-- #  PRIMARY KEY  (`id`),
-- #  KEY `Index_2` USING BTREE (`teacherId`),
-- #  FULLTEXT KEY `Index_3` (`lastName`,`firstName`)
-- #) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci ROW_FORMAT=DYNAMIC;
