--
create sequence referenceid;
alter table reference add code text;
update reference set code = id;
create table temp as select * from reference;
drop table reference;
--
create table reference (id int default nextval('referenceid') primary key, code text, trans_id int, description text, archive_id int, login text, formname text, folder text);
insert into reference (code, trans_id, description) select code, trans_id, description from temp;
drop table temp;
--
create sequence archiveid;
create table archive (id int default nextval('archiveid') primary key, filename text);
create table archivedata (archive_id int references archive (id) on delete cascade, bt text);
--
create table mimetype (extension varchar(32) primary key, contenttype varchar(64));
--
INSERT INTO mimetype (extension, contenttype) VALUES ('acx', 'application/internet-property-stream');
INSERT INTO mimetype (extension, contenttype) VALUES ('ai', 'application/postscript');
INSERT INTO mimetype (extension, contenttype) VALUES ('aif', 'audio/x-aiff');
INSERT INTO mimetype (extension, contenttype) VALUES ('aifc', 'audio/x-aiff');
INSERT INTO mimetype (extension, contenttype) VALUES ('aiff', 'audio/x-aiff');
INSERT INTO mimetype (extension, contenttype) VALUES ('asf', 'video/x-ms-asf');
INSERT INTO mimetype (extension, contenttype) VALUES ('asr', 'video/x-ms-asf');
INSERT INTO mimetype (extension, contenttype) VALUES ('asx', 'video/x-ms-asf');
INSERT INTO mimetype (extension, contenttype) VALUES ('au', 'audio/basic');
INSERT INTO mimetype (extension, contenttype) VALUES ('avi', 'video/x-msvideo');
INSERT INTO mimetype (extension, contenttype) VALUES ('axs', 'application/olescript');
INSERT INTO mimetype (extension, contenttype) VALUES ('bas', 'text/plain');
INSERT INTO mimetype (extension, contenttype) VALUES ('bcpio', 'application/x-bcpio');
INSERT INTO mimetype (extension, contenttype) VALUES ('bin', 'application/octet-stream');
INSERT INTO mimetype (extension, contenttype) VALUES ('bmp', 'image/bmp');
INSERT INTO mimetype (extension, contenttype) VALUES ('c', 'text/plain');
INSERT INTO mimetype (extension, contenttype) VALUES ('cat', 'application/vnd.ms-pkiseccat');
INSERT INTO mimetype (extension, contenttype) VALUES ('cdf', 'application/x-cdf');
INSERT INTO mimetype (extension, contenttype) VALUES ('cer', 'application/x-x509-ca-cert');
INSERT INTO mimetype (extension, contenttype) VALUES ('class', 'application/octet-stream');
INSERT INTO mimetype (extension, contenttype) VALUES ('clp', 'application/x-msclip');
INSERT INTO mimetype (extension, contenttype) VALUES ('cmx', 'image/x-cmx');
INSERT INTO mimetype (extension, contenttype) VALUES ('cod', 'image/cis-cod');
INSERT INTO mimetype (extension, contenttype) VALUES ('cpio', 'application/x-cpio');
INSERT INTO mimetype (extension, contenttype) VALUES ('crd', 'application/x-mscardfile');
INSERT INTO mimetype (extension, contenttype) VALUES ('crl', 'application/pkix-crl');
INSERT INTO mimetype (extension, contenttype) VALUES ('crt', 'application/x-x509-ca-cert');
INSERT INTO mimetype (extension, contenttype) VALUES ('csh', 'application/x-csh');
INSERT INTO mimetype (extension, contenttype) VALUES ('css', 'text/css');
INSERT INTO mimetype (extension, contenttype) VALUES ('dcr', 'application/x-director');
INSERT INTO mimetype (extension, contenttype) VALUES ('der', 'application/x-x509-ca-cert');
INSERT INTO mimetype (extension, contenttype) VALUES ('dir', 'application/x-director');
INSERT INTO mimetype (extension, contenttype) VALUES ('dll', 'application/x-msdownload');
INSERT INTO mimetype (extension, contenttype) VALUES ('dms', 'application/octet-stream');
INSERT INTO mimetype (extension, contenttype) VALUES ('doc', 'application/msword');
INSERT INTO mimetype (extension, contenttype) VALUES ('dot', 'application/msword');
INSERT INTO mimetype (extension, contenttype) VALUES ('dvi', 'application/x-dvi');
INSERT INTO mimetype (extension, contenttype) VALUES ('dxr', 'application/x-director');
INSERT INTO mimetype (extension, contenttype) VALUES ('eps', 'application/postscript');
INSERT INTO mimetype (extension, contenttype) VALUES ('etx', 'text/x-setext');
INSERT INTO mimetype (extension, contenttype) VALUES ('evy', 'application/envoy');
INSERT INTO mimetype (extension, contenttype) VALUES ('exe', 'application/octet-stream');
INSERT INTO mimetype (extension, contenttype) VALUES ('fif', 'application/fractals');
INSERT INTO mimetype (extension, contenttype) VALUES ('flr', 'x-world/x-vrml');
INSERT INTO mimetype (extension, contenttype) VALUES ('gif', 'image/gif');
INSERT INTO mimetype (extension, contenttype) VALUES ('gtar', 'application/x-gtar');
INSERT INTO mimetype (extension, contenttype) VALUES ('gz', 'application/x-gzip');
INSERT INTO mimetype (extension, contenttype) VALUES ('h', 'text/plain');
INSERT INTO mimetype (extension, contenttype) VALUES ('hdf', 'application/x-hdf');
INSERT INTO mimetype (extension, contenttype) VALUES ('hlp', 'application/winhlp');
INSERT INTO mimetype (extension, contenttype) VALUES ('hqx', 'application/mac-binhex40');
INSERT INTO mimetype (extension, contenttype) VALUES ('hta', 'application/hta');
INSERT INTO mimetype (extension, contenttype) VALUES ('htc', 'text/x-component');
INSERT INTO mimetype (extension, contenttype) VALUES ('htm', 'text/html');
INSERT INTO mimetype (extension, contenttype) VALUES ('html', 'text/html');
INSERT INTO mimetype (extension, contenttype) VALUES ('htt', 'text/webviewhtml');
INSERT INTO mimetype (extension, contenttype) VALUES ('ico', 'image/x-icon');
INSERT INTO mimetype (extension, contenttype) VALUES ('ief', 'image/ief');
INSERT INTO mimetype (extension, contenttype) VALUES ('iii', 'application/x-iphone');
INSERT INTO mimetype (extension, contenttype) VALUES ('ins', 'application/x-internet-signup');
INSERT INTO mimetype (extension, contenttype) VALUES ('isp', 'application/x-internet-signup');
INSERT INTO mimetype (extension, contenttype) VALUES ('jfif', 'image/pipeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('jpe', 'image/jpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('jpeg', 'image/jpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('jpg', 'image/jpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('js', 'application/x-javascript');
INSERT INTO mimetype (extension, contenttype) VALUES ('latex', 'application/x-latex');
INSERT INTO mimetype (extension, contenttype) VALUES ('lha', 'application/octet-stream');
INSERT INTO mimetype (extension, contenttype) VALUES ('lsf', 'video/x-la-asf');
INSERT INTO mimetype (extension, contenttype) VALUES ('lsx', 'video/x-la-asf');
INSERT INTO mimetype (extension, contenttype) VALUES ('lzh', 'application/octet-stream');
INSERT INTO mimetype (extension, contenttype) VALUES ('m13', 'application/x-msmediaview');
INSERT INTO mimetype (extension, contenttype) VALUES ('m14', 'application/x-msmediaview');
INSERT INTO mimetype (extension, contenttype) VALUES ('m3u', 'audio/x-mpegurl');
INSERT INTO mimetype (extension, contenttype) VALUES ('man', 'application/x-troff-man');
INSERT INTO mimetype (extension, contenttype) VALUES ('mdb', 'application/x-msaccess');
INSERT INTO mimetype (extension, contenttype) VALUES ('me', 'application/x-troff-me');
INSERT INTO mimetype (extension, contenttype) VALUES ('mht', 'message/rfc822');
INSERT INTO mimetype (extension, contenttype) VALUES ('mhtml', 'message/rfc822');
INSERT INTO mimetype (extension, contenttype) VALUES ('mid', 'audio/mid');
INSERT INTO mimetype (extension, contenttype) VALUES ('mny', 'application/x-msmoney');
INSERT INTO mimetype (extension, contenttype) VALUES ('mov', 'video/quicktime');
INSERT INTO mimetype (extension, contenttype) VALUES ('movie', 'video/x-sgi-movie');
INSERT INTO mimetype (extension, contenttype) VALUES ('mp2', 'video/mpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('mp3', 'audio/mpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('mpa', 'video/mpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('mpe', 'video/mpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('mpeg', 'video/mpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('mpg', 'video/mpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('mpp', 'application/vnd.ms-project');
INSERT INTO mimetype (extension, contenttype) VALUES ('mpv2', 'video/mpeg');
INSERT INTO mimetype (extension, contenttype) VALUES ('ms', 'application/x-troff-ms');
INSERT INTO mimetype (extension, contenttype) VALUES ('mvb', 'application/x-msmediaview');
INSERT INTO mimetype (extension, contenttype) VALUES ('nws', 'message/rfc822');
INSERT INTO mimetype (extension, contenttype) VALUES ('oda', 'application/oda');
INSERT INTO mimetype (extension, contenttype) VALUES ('ods', 'application/vnd.oasis.opendocument.spreadsheet');
INSERT INTO mimetype (extension, contenttype) VALUES ('odt', 'application/vnd.oasis.opendocument.document');
INSERT INTO mimetype (extension, contenttype) VALUES ('p10', 'application/pkcs10');
INSERT INTO mimetype (extension, contenttype) VALUES ('p12', 'application/x-pkcs12');
INSERT INTO mimetype (extension, contenttype) VALUES ('p7b', 'application/x-pkcs7-certificates');
INSERT INTO mimetype (extension, contenttype) VALUES ('p7c', 'application/x-pkcs7-mime');
INSERT INTO mimetype (extension, contenttype) VALUES ('p7m', 'application/x-pkcs7-mime');
INSERT INTO mimetype (extension, contenttype) VALUES ('p7r', 'application/x-pkcs7-certreqresp');
INSERT INTO mimetype (extension, contenttype) VALUES ('p7s', 'application/x-pkcs7-signature');
INSERT INTO mimetype (extension, contenttype) VALUES ('pbm', 'image/x-portable-bitmap');
INSERT INTO mimetype (extension, contenttype) VALUES ('pdf', 'application/pdf');
INSERT INTO mimetype (extension, contenttype) VALUES ('pfx', 'application/x-pkcs12');
INSERT INTO mimetype (extension, contenttype) VALUES ('pgm', 'image/x-portable-graymap');
INSERT INTO mimetype (extension, contenttype) VALUES ('pko', 'application/ynd.ms-pkipko');
INSERT INTO mimetype (extension, contenttype) VALUES ('pma', 'application/x-perfmon');
INSERT INTO mimetype (extension, contenttype) VALUES ('pmc', 'application/x-perfmon');
INSERT INTO mimetype (extension, contenttype) VALUES ('pml', 'application/x-perfmon');
INSERT INTO mimetype (extension, contenttype) VALUES ('pmr', 'application/x-perfmon');
INSERT INTO mimetype (extension, contenttype) VALUES ('pmw', 'application/x-perfmon');
INSERT INTO mimetype (extension, contenttype) VALUES ('png', 'image/png');
INSERT INTO mimetype (extension, contenttype) VALUES ('pnm', 'image/x-portable-anymap');
INSERT INTO mimetype (extension, contenttype) VALUES ('pot', 'application/vnd.ms-powerpoint');
INSERT INTO mimetype (extension, contenttype) VALUES ('ppm', 'image/x-portable-pixmap');
INSERT INTO mimetype (extension, contenttype) VALUES ('pps', 'application/vnd.ms-powerpoint');
INSERT INTO mimetype (extension, contenttype) VALUES ('ppt', 'application/vnd.ms-powerpoint');
INSERT INTO mimetype (extension, contenttype) VALUES ('prf', 'application/pics-rules');
INSERT INTO mimetype (extension, contenttype) VALUES ('ps', 'application/postscript');
INSERT INTO mimetype (extension, contenttype) VALUES ('pub', 'application/x-mspublisher');
INSERT INTO mimetype (extension, contenttype) VALUES ('qt', 'video/quicktime');
INSERT INTO mimetype (extension, contenttype) VALUES ('ra', 'audio/x-pn-realaudio');
INSERT INTO mimetype (extension, contenttype) VALUES ('ram', 'audio/x-pn-realaudio');
INSERT INTO mimetype (extension, contenttype) VALUES ('ras', 'image/x-cmu-raster');
INSERT INTO mimetype (extension, contenttype) VALUES ('rgb', 'image/x-rgb');
INSERT INTO mimetype (extension, contenttype) VALUES ('rmi', 'audio/mid');
INSERT INTO mimetype (extension, contenttype) VALUES ('roff', 'application/x-troff');
INSERT INTO mimetype (extension, contenttype) VALUES ('rtf', 'application/rtf');
INSERT INTO mimetype (extension, contenttype) VALUES ('rtx', 'text/richtext');
INSERT INTO mimetype (extension, contenttype) VALUES ('scd', 'application/x-msschedule');
INSERT INTO mimetype (extension, contenttype) VALUES ('sct', 'text/scriptlet');
INSERT INTO mimetype (extension, contenttype) VALUES ('setpay', 'application/set-payment-initiation');
INSERT INTO mimetype (extension, contenttype) VALUES ('setreg', 'application/set-registration-initiation');
INSERT INTO mimetype (extension, contenttype) VALUES ('sh', 'application/x-sh');
INSERT INTO mimetype (extension, contenttype) VALUES ('shar', 'application/x-shar');
INSERT INTO mimetype (extension, contenttype) VALUES ('sit', 'application/x-stuffit');
INSERT INTO mimetype (extension, contenttype) VALUES ('snd', 'audio/basic');
INSERT INTO mimetype (extension, contenttype) VALUES ('spc', 'application/x-pkcs7-certificates');
INSERT INTO mimetype (extension, contenttype) VALUES ('spl', 'application/futuresplash');
INSERT INTO mimetype (extension, contenttype) VALUES ('src', 'application/x-wais-source');
INSERT INTO mimetype (extension, contenttype) VALUES ('sst', 'application/vnd.ms-pkicertstore');
INSERT INTO mimetype (extension, contenttype) VALUES ('stl', 'application/vnd.ms-pkistl');
INSERT INTO mimetype (extension, contenttype) VALUES ('stm', 'text/html');
INSERT INTO mimetype (extension, contenttype) VALUES ('svg', 'image/svg+xml');
INSERT INTO mimetype (extension, contenttype) VALUES ('sv4cpio', 'application/x-sv4cpio');
INSERT INTO mimetype (extension, contenttype) VALUES ('sv4crc', 'application/x-sv4crc');
INSERT INTO mimetype (extension, contenttype) VALUES ('swf', 'application/x-shockwave-flash');
INSERT INTO mimetype (extension, contenttype) VALUES ('t', 'application/x-troff');
INSERT INTO mimetype (extension, contenttype) VALUES ('tar', 'application/x-tar');
INSERT INTO mimetype (extension, contenttype) VALUES ('tcl', 'application/x-tcl');
INSERT INTO mimetype (extension, contenttype) VALUES ('tex', 'application/x-tex');
INSERT INTO mimetype (extension, contenttype) VALUES ('texi', 'application/x-texinfo');
INSERT INTO mimetype (extension, contenttype) VALUES ('texinfo', 'application/x-texinfo');
INSERT INTO mimetype (extension, contenttype) VALUES ('tgz', 'application/x-compressed');
INSERT INTO mimetype (extension, contenttype) VALUES ('tif', 'image/tiff');
INSERT INTO mimetype (extension, contenttype) VALUES ('tiff', 'image/tiff');
INSERT INTO mimetype (extension, contenttype) VALUES ('tr', 'application/x-troff');
INSERT INTO mimetype (extension, contenttype) VALUES ('trm', 'application/x-msterminal');
INSERT INTO mimetype (extension, contenttype) VALUES ('tsv', 'text/tab-separated-values');
INSERT INTO mimetype (extension, contenttype) VALUES ('txt', 'text/plain');
INSERT INTO mimetype (extension, contenttype) VALUES ('uls', 'text/iuls');
INSERT INTO mimetype (extension, contenttype) VALUES ('ustar', 'application/x-ustar');
INSERT INTO mimetype (extension, contenttype) VALUES ('vcf', 'text/x-vcard');
INSERT INTO mimetype (extension, contenttype) VALUES ('vrml', 'x-world/x-vrml');
INSERT INTO mimetype (extension, contenttype) VALUES ('wav', 'audio/x-wav');
INSERT INTO mimetype (extension, contenttype) VALUES ('wcm', 'application/vnd.ms-works');
INSERT INTO mimetype (extension, contenttype) VALUES ('wdb', 'application/vnd.ms-works');
INSERT INTO mimetype (extension, contenttype) VALUES ('wks', 'application/vnd.ms-works');
INSERT INTO mimetype (extension, contenttype) VALUES ('wmf', 'application/x-msmetafile');
INSERT INTO mimetype (extension, contenttype) VALUES ('wps', 'application/vnd.ms-works');
INSERT INTO mimetype (extension, contenttype) VALUES ('wri', 'application/x-mswrite');
INSERT INTO mimetype (extension, contenttype) VALUES ('wrl', 'x-world/x-vrml');
INSERT INTO mimetype (extension, contenttype) VALUES ('wrz', 'x-world/x-vrml');
INSERT INTO mimetype (extension, contenttype) VALUES ('xaf', 'x-world/x-vrml');
INSERT INTO mimetype (extension, contenttype) VALUES ('xbm', 'image/x-xbitmap');
INSERT INTO mimetype (extension, contenttype) VALUES ('xla', 'application/vnd.ms-excel');
INSERT INTO mimetype (extension, contenttype) VALUES ('xlc', 'application/vnd.ms-excel');
INSERT INTO mimetype (extension, contenttype) VALUES ('xlm', 'application/vnd.ms-excel');
INSERT INTO mimetype (extension, contenttype) VALUES ('xls', 'application/vnd.ms-excel');
INSERT INTO mimetype (extension, contenttype) VALUES ('xlt', 'application/vnd.ms-excel');
INSERT INTO mimetype (extension, contenttype) VALUES ('xlw', 'application/vnd.ms-excel');
INSERT INTO mimetype (extension, contenttype) VALUES ('xof', 'x-world/x-vrml');
INSERT INTO mimetype (extension, contenttype) VALUES ('xpm', 'image/x-xpixmap');
INSERT INTO mimetype (extension, contenttype) VALUES ('xwd', 'image/x-xwindowdump');
INSERT INTO mimetype (extension, contenttype) VALUES ('z', 'application/x-compress');
INSERT INTO mimetype (extension, contenttype) VALUES ('zip', 'application/zip');
--
update defaults set fldvalue = '3.1.0' where fldname = 'version';

