--
-- Copyright (c) 1998-2009 Luna Imaging, Inc.  All Rights Reserved.
--
-- This software is confidential and proprietary information of
-- Luna Imaging, Inc.  ("Confidential Information").  You shall not
-- disclose such Confidential Information and shall use it only in
-- accordance with the terms of the license agreement you entered into
-- with Luna Imaging, Inc.
--
-- The software may not be copied, reproduced, translated or reduced to
-- any electronic medium or machine-readable form without
-- the prior written consent of Luna Imaging.
--
-- You are not allowed to distribute the binary and source code
-- (if released) to third parties, without the prior written consent from
-- Luna Imaging.
--
-- You are not allowed to reverse engineer, disassemble or decompile
-- code, or make any modifications of the binary or source code, remove
-- or alter any trademark, logo, copyright or other proprietary notices,
-- legends, symbols, or labels in the Software.
--
-- You are not allowed to sub-license the Software or any derivative
-- work based on or derived from the Software.
--
-- LUNA IMAGING MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY
-- OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
-- TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-- PURPOSE, OR NON-INFRINGEMENT, LUNA IMAGING SHALL NOT BE LIABLE FOR ANY
-- DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
-- DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
--

--
-- Create Table Statements for MEDIAFIELDRELATIONS
--  

CREATE TABLE MEDIAFIELDRELATIONS(
    SOURCESTANDARDID VARCHAR(50) NOT NULL,
    SOURCEFIELDNAME VARCHAR(50) NOT NULL,
    DESTSTANDARDID INTEGER NOT NULL,
    DESTFIELDNAME VARCHAR(50) NOT NULL,
    PRIMARY KEY (`SOURCESTANDARDID`,`SOURCEFIELDNAME`,`DESTSTANDARDID`,`DESTFIELDNAME`) 
) DEFAULT CHARACTER SET utf8;


--
-- Create Table Statements for MEDIAFIELDSTANDARDS
--  
 
CREATE TABLE MEDIAFIELDSTANDARDS(
    STANDARDID INTEGER NOT NULL,
    STANDARDNAME VARCHAR(50) NULL,
    PRIMARY KEY (`STANDARDID`) 
) DEFAULT CHARACTER SET utf8;
    

--
-- Create Table Statements for MEDIASTANDARDFIELDS
--  
      
CREATE TABLE MEDIASTANDARDFIELDS(
    STANDARDFIELDID INTEGER NOT NULL,
    STANDARDFIELDNAME VARCHAR(50),
    STANDARDFIELDDISPLAYORDER INTEGER NOT NULL,
    STANDARDID INTEGER NOT NULL,
    PRIMARY KEY (`STANDARDFIELDID`,`STANDARDID`) 
) DEFAULT CHARACTER SET utf8;


--
-- Create Table Statements for TINYURLS
--  

  CREATE TABLE TINYURLS(
    ID INTEGER NOT NULL AUTO_INCREMENT,
    TOKEN VARCHAR(50) NOT NULL,
    MAPPEDURL VARCHAR(4000) NOT NULL,
    CREATEDTIMESTAMP VARCHAR(50) NOT NULL,
  PRIMARY KEY (`ID`) 
) DEFAULT CHARACTER SET utf8;


UPDATE CREDENTIALCOLLECTIONMAP SET ANNOTATIONENABLED = 0 WHERE ANNOTATIONENABLED IS NULL;
ALTER TABLE CREDENTIALCOLLECTIONMAP MODIFY ANNOTATIONENABLED BOOLEAN NOT NULL;    

UPDATE CREDENTIALCOLLECTIONMAP SET MAXEXPORTRESOLUTION = 4 WHERE MAXEXPORTRESOLUTION IS NULL;
ALTER TABLE CREDENTIALCOLLECTIONMAP MODIFY MAXEXPORTRESOLUTION INTEGER NOT NULL;   

ALTER TABLE EXTERNALMEDIA MODIFY DISPLAYTITLE VARCHAR(1000) NULL;
--
-- Default Inserts for Standards
--  

INSERT INTO MEDIAFIELDSTANDARDS ( STANDARDID, STANDARDNAME ) VALUES ( 1, 'DUBLIN CORE' );
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (1, 'TITLE', 1, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (2, 'CREATOR', 2, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (3, 'SUBJECT', 3, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (4, 'DESCRIPTION', 4, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (5, 'PUBLISHER', 5, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (6, 'CONTRIBUTOR', 6, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (7, 'DATE', 7, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (8, 'TYPE', 8, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (9, 'FORMAT', 9, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (10, 'IDENTIFIER', 10, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (11, 'SOURCE', 11, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (12, 'LANGUAGE', 12, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (13, 'RELATION', 13, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (14, 'COVERAGE', 14, 1);
INSERT INTO MEDIASTANDARDFIELDS ( STANDARDFIELDID, STANDARDFIELDNAME, STANDARDFIELDDISPLAYORDER, STANDARDID ) VALUES (15, 'RIGHTS', 15, 1);

INSERT INTO APPLICATIONCONFIGURATION(ATTRIBUTE,ATTRIBUTEVALUE)VALUES('rssEnabled','true');
INSERT INTO APPLICATIONCONFIGURATION(ATTRIBUTE,ATTRIBUTEVALUE)VALUES('linkSearchEnabled','true');
INSERT INTO APPLICATIONCONFIGURATION(ATTRIBUTE,ATTRIBUTEVALUE)VALUES('linkSearchExcludedFields','Collection, Image ID, Resolution Size, Format, Media Type, File Name, Width, Height, Originating Url');
INSERT INTO APPLICATIONCONFIGURATION(ATTRIBUTE,ATTRIBUTEVALUE)VALUES('linkSearchHideDelayMilliSec','1000');
INSERT INTO APPLICATIONCONFIGURATION(ATTRIBUTE,ATTRIBUTEVALUE)VALUES('linkSearchShowDelayMilliSec','50');