-- 2014-11-09	 To facilitate dynamic customization of input dialog for a feature
ALTER TABLE FEATUREDEFINITION ADD DIALOGJAVASCRIPT TEXT;

-- 2015-01-28	 To facilitate group ownership of a document
ALTER TABLE DOCUMENT ADD GROUPID VARCHAR(60);

-- 2015-05-01	 To facilitate applying diffent levels of copying protection to image display
ALTER TABLE SURROGATEIMAGE ADD PROTECTLEVEL INTEGER default 0;

-- 2016-06-14	 To facilitate options from Cat's Collation Editor 
ALTER TABLE REGULARIZATIONRULE ADD RULEOPTIONS INTEGER default 0;
ALTER TABLE REGULARIZATIONRULE ADD CREATEDATE timestamp default CURRENT_TIMESTAMP;

CREATE TABLE `REGULARIZATIONRULEEXCEPTION` (
  `REGULARIZATIONRULEID` int(11) NOT NULL,
  `VERSE` int(11) NOT NULL,
  `GROUPNAME` varchar(40) NOT NULL DEFAULT 'Unassigned',
  `USERID` varchar(200) DEFAULT NULL,
  `CREATEDATE` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`REGULARIZATIONRULEID`,`VERSE`,`GROUPNAME`,`USERID`),
  KEY `BIBLICALCONTENTVERSE` (`VERSE`,`GROUPNAME`,`USERID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

-- 2016-10-07	To facilitate per document versification
ALTER TABLE DOCUMENT ADD V11N VARCHAR(60) DEFAULT NULL;

-- 2016-10-30	To facilitate per project transcription attribution
ALTER TABLE PROJECT ADD TRANSCRIPTIONATTRIBUTION VARCHAR(254) DEFAULT NULL;

-- 2017-07-13	To have some semblance of designating which fragments
--		of a distributed page are at what institution
--		using image per fragment is not ideal but is a reasonable
--		compromise
ALTER TABLE SURROGATEIMAGE ADD SHELFID int(11);

-- 2018-05-28	Start of mapping Institution to geonames.org
ALTER TABLE INSTITUTION ADD GEONAME varchar(150);

-- 2018-05-31	Contains the official abbreviation as referred to by
--		the Coptic scholarly community or allows other
--		projects to specify their own custom names or limit institutes
--		to their project interests by filling in this field and choosing
--		the catalog option to include only institutes with custom names
ALTER TABLE INSTITUTION ADD `CUSTOMINSTNAME` varchar(120) DEFAULT NULL;

-- 2018-06-25	Added for quick computation of project stats
ALTER TABLE TRANSCRIPTIONPAGE ADD LINECOUNT int(11) DEFAULT NULL;
ALTER TABLE TRANSCRIPTIONPAGE ADD WORDCOUNT int(11) DEFAULT NULL;

-- 2018-08-05	Added Münster summer updates for retaining indexing order
ALTER TABLE PAGE ADD INDEXSTRINGORIG varchar(100) DEFAULT NULL;
-- 2018-08-05	... handling a secondary document group to differentiate transcriptions from editing
ALTER TABLE PROJECT ADD DOCUMENTGROUPIDSECONDARY int(11) DEFAULT NULL;
-- 2018-08-05	... letting students change stage of their assignments
ALTER TABLE TASK ADD STAGE INTEGER DEFAULT 0;
alter table TASK drop primary key;
alter table TASK add TASKID int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY;
create unique index TASKPROJECTASSIGNMENTS on TASK(`TASKTYPEID`,`OBJECTID`,`ASSIGNEDTO`,`PROJECTID`,`OBJECTPART`);
-- 2018-08-05	... letting projects define their own stages of each task
ALTER TABLE PROJECT ADD TASKSTAGEDEFINITIONS varchar(100) DEFAULT NULL;

-- 2018-08-16	Migrated final odd columns out of DOCUMENT into FEATURES
alter table DOCUMENT drop column DESTROYED;
alter table DOCUMENT drop column FORMERGANUMBER;
alter table DOCUMENT drop column PALEMPSESTOTHER;
alter table DOCUMENT drop column PALEMPSESTUNDER;
alter table DOCUMENT drop column SUPPLEMENTOF;
alter table DOCUMENT drop column KLFOOTNOTES;
alter table DOCUMENT drop column FORMATSCROLL;
alter table DOCUMENT drop column COMMENT;
-- 2018-08-16	Increased FEATURE STRINGVAL size to allow larger values
alter table FEATURE modify STRINGVAL1 VARCHAR(500);
alter table FEATURE modify STRINGVAL2 VARCHAR(500);
