1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

Make database install/upgrade provider aware

Ground work for installing and upgrading database schema based upon DB provider (MySQL, PostgresSQL, SQL Server, etc.)

Cleaned up legacy cruft, refactored, commented and made simpler for to support additional database providers.
This commit is contained in:
Harvey Kandola 2018-09-14 12:50:30 +01:00
parent cf1e1ff943
commit 2336dab69f
38 changed files with 1401 additions and 1208 deletions

View file

@ -0,0 +1,282 @@
-- SQL to set up the Documize database
DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`firstname` VARCHAR(500) NOT NULL,
`lastname` VARCHAR(500) NOT NULL,
`email` VARCHAR(250) NOT NULL UNIQUE,
`initials` VARCHAR(10) NOT NULL DEFAULT "",
`password` VARCHAR(500) NOT NULL DEFAULT "",
`salt` VARCHAR(100) NOT NULL DEFAULT "",
`reset` VARCHAR(100) NOT NULL DEFAULT "",
`active` BOOL NOT NULL DEFAULT 1,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_user_id` (`id` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `audit`;
CREATE TABLE IF NOT EXISTS `audit` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin,
`pageid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin,
`action` VARCHAR(200) NOT NULL DEFAULT "",
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_audit_id` (`id` ASC),
INDEX `idx_orgid_url` (`orgid`))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `organization`;
CREATE TABLE IF NOT EXISTS `organization` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`company` VARCHAR(500) NOT NULL,
`title` VARCHAR(500) NOT NULL,
`message` VARCHAR(500) NOT NULL,
`url` VARCHAR(200) NOT NULL DEFAULT "",
`domain` VARCHAR(200) NOT NULL DEFAULT "",
`email` VARCHAR(500) NOT NULL DEFAULT "",
`allowanonymousaccess` BOOL NOT NULL DEFAULT 0,
`verified` BOOL NOT NULL DEFAULT 0,
`serial` VARCHAR(50) NOT NULL DEFAULT "",
`active` BOOL NOT NULL DEFAULT 1,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_organization_id` (`id` ASC),
INDEX `idx_organization_url` (`url`),
INDEX `idx_organization_domain` (`domain`))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `account`;
CREATE TABLE IF NOT EXISTS `account` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`editor` BOOL NOT NULL DEFAULT 0,
`admin` BOOL NOT NULL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_account_id` (`id` ASC),
INDEX `idx_account_userid` (`userid` ASC),
INDEX `idx_account_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `label`;
CREATE TABLE IF NOT EXISTS `label` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`label` VARCHAR(255) NOT NULL,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin,
`type` INT NOT NULL DEFAULT 1,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_label_id` (`id` ASC),
INDEX `idx_label_userid` (`userid` ASC),
INDEX `idx_label_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `labelrole`;
CREATE TABLE IF NOT EXISTS `labelrole` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`labelid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`canview` BOOL NOT NULL DEFAULT 0,
`canedit` BOOL NOT NULL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_labelrole_id` (`id` ASC),
INDEX `idx_labelrole_userid` (`userid` ASC),
INDEX `idx_labelrole_labelid` (`labelid` ASC),
INDEX `idx_labelrole_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `document`;
CREATE TABLE IF NOT EXISTS `document` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`labelid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`job` CHAR(36) NOT NULL,
`location` VARCHAR(2000) NOT NULL,
`title` VARCHAR(2000) NOT NULL,
`excerpt` VARCHAR(2000) NOT NULL,
`slug` VARCHAR(2000) NOT NULL,
`tags` VARCHAR(1000) NOT NULL DEFAULT '',
`template` BOOL NOT NULL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_document_id` (`id` ASC),
INDEX `idx_document_orgid` (`orgid` ASC),
INDEX `idx_document_labelid` (`labelid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `page`;
CREATE TABLE IF NOT EXISTS `page` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg',
`level` INT UNSIGNED NOT NULL,
`sequence` DOUBLE NOT NULL,
`title` VARCHAR(2000) NOT NULL,
`body` LONGTEXT,
`revisions` INT UNSIGNED NOT NULL,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_page_id` (`id` ASC),
INDEX `idx_page_orgid` (`orgid` ASC),
INDEX `idx_page_documentid` (`documentid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `pagemeta`;
CREATE TABLE IF NOT EXISTS `pagemeta` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`pageid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`rawbody` LONGBLOB,
`config` JSON,
`externalsource` BOOL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_pageid PRIMARY KEY (pageid),
UNIQUE INDEX `idx_pagemeta_id` (`id` ASC),
INDEX `idx_pagemeta_pageid` (`pageid` ASC),
INDEX `idx_pagemeta_orgid` (`orgid` ASC),
INDEX `idx_pagemeta_documentid` (`documentid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `attachment`;
CREATE TABLE IF NOT EXISTS `attachment` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`job` CHAR(36) NOT NULL,
`fileid` CHAR(10) NOT NULL,
`filename` VARCHAR(255) NOT NULL,
`data` LONGBLOB,
`extension` CHAR(6) NOT NULL,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_attachment_id` (`id` ASC),
INDEX `idx_attachment_orgid` (`orgid` ASC),
INDEX `idx_attachment_documentid` (`documentid` ASC),
INDEX `idx_attachment_job_and_fileid` (`job`,`fileid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `search`;
CREATE TABLE IF NOT EXISTS `search` (
`id` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`level` INT UNSIGNED NOT NULL,
`sequence` DOUBLE NOT NULL,
`documenttitle` VARCHAR(2000) NOT NULL,
`pagetitle` VARCHAR(2000) NOT NULL,
`slug` VARCHAR(2000) NOT NULL,
`body` LONGTEXT,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_search_id` (`id` ASC),
INDEX `idx_search_orgid` (`orgid` ASC),
INDEX `idx_search_documentid` (`documentid` ASC),
INDEX `idx_search_sequence` (`sequence` ASC),
FULLTEXT(`pagetitle`,`body`))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = MyISAM;
-- FULLTEXT search requires MyISAM and NOT InnoDB
DROP TABLE IF EXISTS `revision`;
CREATE TABLE IF NOT EXISTS `revision` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`ownerid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`pageid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg',
`title` VARCHAR(2000) NOT NULL,
`body` LONGTEXT,
`rawbody` LONGBLOB,
`config` JSON,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_revision_id` (`id` ASC),
INDEX `idx_revision_orgid` (`orgid` ASC),
INDEX `idx_revision_documentid` (`documentid` ASC),
INDEX `idx_revision_pageid` (`pageid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
DROP TABLE IF EXISTS `config`;
CREATE TABLE IF NOT EXISTS `config` (
`key` CHAR(255) NOT NULL,
`config` JSON,
UNIQUE INDEX `idx_config_area` (`key` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
INSERT INTO `config` VALUES ('SMTP','{\"userid\": \"\",\"password\": \"\",\"host\": \"\",\"port\": \"\",\"sender\": \"\"}');
INSERT INTO `config` VALUES ('FILEPLUGINS',
'[{\"Comment\": \"Disable (or not) built-in html import (NOTE: no Plugin name)\",\"Disabled\": false,\"API\": \"Convert\",\"Actions\": [\"htm\",\"html\"]},{\"Comment\": \"Disable (or not) built-in Documize API import used from SDK (NOTE: no Plugin name)\",\"Disabled\": false,\"API\": \"Convert\",\"Actions\": [\"documizeapi\"]}]');
INSERT INTO `config` VALUES ('META','{\"database\": \"db_00000.sql\"}');
INSERT INTO `config` VALUES ('SECTION-GITHUB', '{\"clientID\": \"\", \"clientSecret\": \"\", \"authorizationCallbackURL\": \"https://localhost:5001/api/public/validate?section=github\"}');
INSERT INTO `config` VALUES ('SECTION-TRELLO','{\"appKey\": \"\"}');
DROP TABLE IF EXISTS `userconfig`;
CREATE TABLE IF NOT EXISTS `userconfig` (
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`key` CHAR(255) NOT NULL,
`config` JSON,
UNIQUE INDEX `idx_userconfig_orguserkey` (`orgid`, `userid`, `key` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;

View file

@ -0,0 +1,18 @@
/* enterprise edition */
DROP TABLE IF EXISTS `share`;
CREATE TABLE IF NOT EXISTS `share` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`email` VARCHAR(250) NOT NULL DEFAULT '',
`message` VARCHAR(500) NOT NULL DEFAULT '',
`viewed` VARCHAR(500) NOT NULL DEFAULT '',
`secret` VARCHAR(200) NOT NULL DEFAULT '',
`expires` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`active` BOOL NOT NULL DEFAULT 1,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;

View file

@ -0,0 +1,15 @@
/* enterprise edition */
DROP TABLE IF EXISTS `feedback`;
CREATE TABLE IF NOT EXISTS `feedback` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`email` VARCHAR(250) NOT NULL DEFAULT '',
`feedback` LONGTEXT,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;

View file

@ -0,0 +1,2 @@
/* community edition */
ALTER TABLE user ADD COLUMN `global` BOOL NOT NULL DEFAULT 0 AFTER `initials`;

View file

@ -0,0 +1,20 @@
/* community edition */
DROP TABLE IF EXISTS `link`;
CREATE TABLE IF NOT EXISTS `link` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`folderid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`sourcedocumentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`sourcepageid` CHAR(16) NOT NULL COLLATE utf8_bin,
`linktype` CHAR(16) NOT NULL COLLATE utf8_bin,
`targetdocumentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`targetid` CHAR(16) NOT NULL DEFAULT '' COLLATE utf8_bin,
`orphan` BOOL NOT NULL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;

View file

@ -0,0 +1,6 @@
/* community edition */
ALTER TABLE page ADD COLUMN `pagetype` CHAR(10) NOT NULL DEFAULT 'section' AFTER `contenttype`;
-- UPDATE page SET pagetype='tab', sequence=0 WHERE refid IN (SELECT pageid FROM pagemeta WHERE externalsource=1);
ALTER TABLE revision ADD COLUMN `pagetype` CHAR(10) NOT NULL DEFAULT 'section' AFTER `contenttype`;
UPDATE revision SET pagetype='tab' WHERE pageid IN (SELECT pageid FROM pagemeta WHERE externalsource=1);

View file

@ -0,0 +1,16 @@
/* enterprise edition */
DROP TABLE IF EXISTS `participant`;
CREATE TABLE IF NOT EXISTS `participant` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`roletype` CHAR(1) NOT NULL DEFAULT 'I' COLLATE utf8_bin,
`lastviewed` TIMESTAMP NULL,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_participant_documentid` (`documentid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;

View file

@ -0,0 +1,2 @@
/* community edition */
ALTER TABLE document ADD COLUMN `layout` CHAR(10) NOT NULL DEFAULT 'doc' AFTER `template`;

View file

@ -0,0 +1,18 @@
/* community edition */
DROP TABLE IF EXISTS `pin`;
CREATE TABLE IF NOT EXISTS `pin` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`labelid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`documentid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`sequence` INT UNSIGNED NOT NULL DEFAULT 99,
`pin` CHAR(20) NOT NULL DEFAULT '' COLLATE utf8_bin,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_pin_userid` (`userid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;

View file

@ -0,0 +1,31 @@
/* community edition */
DROP TABLE IF EXISTS `block`;
CREATE TABLE IF NOT EXISTS `block` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`labelid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg',
`pagetype` CHAR(10) NOT NULL DEFAULT 'section',
`title` VARCHAR(2000) NOT NULL,
`body` LONGTEXT,
`excerpt` VARCHAR(2000) NOT NULL,
`used` INT UNSIGNED NOT NULL,
`rawbody` LONGBLOB,
`config` JSON,
`externalsource` BOOL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_block_refid` (`refid` ASC),
INDEX `idx_block_labelid` (`labelid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
ALTER TABLE page ADD COLUMN `blockid` CHAR(16) NOT NULL DEFAULT '' COLLATE utf8_bin AFTER `pagetype`;
/* Note: version history table does not need blockid field as they are populated once during page creation:
- you cannot mark an existing section as a preset
- a page is only marked as preset during it's creation (e.g. created from an existing preset)
*/

View file

@ -0,0 +1,91 @@
/* community edition */
DROP TABLE IF EXISTS `useractivity`;
CREATE TABLE IF NOT EXISTS `useractivity` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`labelid` CHAR(16) NOT NULL COLLATE utf8_bin,
`sourceid` CHAR(16) NOT NULL COLLATE utf8_bin,
`sourcetype` INT NOT NULL DEFAULT 0,
`activitytype` INT NOT NULL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_activity_orgid` (`orgid` ASC),
INDEX `idx_activity_userid` (`userid` ASC),
INDEX `idx_activity_sourceid` (`sourceid` ASC),
INDEX `idx_activity_activitytype` (`activitytype` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
/* Note:
* - this table replaces the soon-to-be-deprecated audit log table
* - we migrate existing data where there is a migration path */
INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created)
SELECT a.orgid, a.userid, labelid, a.documentid as sourceid, 2 as sourcetype, 1 as activitytype, a.created
FROM audit a, document d
WHERE action='add-document' AND d.refid=a.documentid;
INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created)
SELECT a.orgid, a.userid, labelid, a.documentid as sourceid, 2 as sourcetype, 1 as activitytype, a.created
FROM audit a, document d
WHERE action='add-page' AND d.refid=a.documentid;
INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created)
SELECT a.orgid, a.userid, labelid, a.documentid as sourceid, 2 as sourcetype, 2 as activitytype, a.created
FROM audit a, document d
WHERE action='get-document' AND d.refid=a.documentid;
INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created)
SELECT a.orgid, a.userid, labelid, a.documentid as sourceid, 2 as sourcetype, 3 as activitytype, a.created
FROM audit a, document d
WHERE action='update-page' AND d.refid=a.documentid;
INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created)
SELECT a.orgid, a.userid, labelid, a.documentid as sourceid, 2 as sourcetype, 3 as activitytype, a.created
FROM audit a, document d
WHERE action='re-sequence-page' AND d.refid=a.documentid;
INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created)
SELECT a.orgid, a.userid, labelid, a.documentid as sourceid, 2 as sourcetype, 3 as activitytype, a.created
FROM audit a, document d
WHERE action='re-level-page' AND d.refid=a.documentid;
INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created)
SELECT a.orgid, a.userid, labelid, a.documentid as sourceid, 2 as sourcetype, 4 as activitytype, a.created
FROM audit a, document d
WHERE action='delete-document' AND d.refid=a.documentid;
INSERT INTO useractivity (orgid, userid, labelid, sourceid, sourcetype, activitytype, created)
SELECT a.orgid, a.userid, labelid, a.documentid as sourceid, 2 as sourcetype, 4 as activitytype, a.created
FROM audit a, document d
WHERE action='remove-page' AND d.refid=a.documentid;
/* enterprise edition */
DROP TABLE IF EXISTS `useraction`;
CREATE TABLE IF NOT EXISTS `useraction` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`requestorid` CHAR(16) NOT NULL COLLATE utf8_bin,
`actiontype` INT NOT NULL DEFAULT 0,
`note` NVARCHAR(2000) NOT NULL DEFAULT '',
`requested` TIMESTAMP NULL,
`due` TIMESTAMP NULL,
`completed` TIMESTAMP NULL,
`iscomplete` BOOL NOT NULL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_useraction_refid` (`refid` ASC),
INDEX `idx_useraction_userid` (`userid` ASC),
INDEX `idx_useraction_documentid` (`documentid` ASC),
INDEX `idx_useraction_requestorid` (`requestorid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;
/* community edition */
ALTER TABLE account ADD COLUMN `active` BOOL NOT NULL DEFAULT 1 AFTER `admin`;

View file

@ -0,0 +1,3 @@
/* community edition */
ALTER TABLE organization ADD COLUMN `authprovider` CHAR(20) NOT NULL DEFAULT 'documize' AFTER `allowanonymousaccess`;
ALTER TABLE organization ADD COLUMN `authconfig` JSON AFTER `authprovider`;

View file

@ -0,0 +1,3 @@
/* community edition */
ALTER TABLE document ALTER COLUMN `layout` SET DEFAULT 'section';
UPDATE document SET layout='section';

View file

@ -0,0 +1,16 @@
/* community edition */
DROP TABLE IF EXISTS `userevent`;
CREATE TABLE IF NOT EXISTS `userevent` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`eventtype` VARCHAR(100) NOT NULL DEFAULT '',
`ip` VARCHAR(39) NOT NULL COLLATE utf8_bin DEFAULT '',
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_userevent_orgid` (`orgid` ASC),
INDEX `idx_userevent_userid` (`userid` ASC),
INDEX `idx_userevent_eventtype` (`eventtype` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB;

View file

@ -0,0 +1,3 @@
/* community edition */
ALTER TABLE organization ADD COLUMN `service` VARCHAR(100) NOT NULL DEFAULT 'https://api.documize.com' AFTER `domain`;

View file

@ -0,0 +1,65 @@
/* community edition */
ALTER DATABASE documize CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE account CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE attachment CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE block CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE config CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE document CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE feedback CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE label CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE labelrole CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE link CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE organization CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE page CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE pagemeta CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE participant CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE pin CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE revision CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE search CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE share CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE user CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE useraction CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE useractivity CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE userconfig CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE userevent CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
DROP TABLE IF EXISTS `search_old`;
RENAME TABLE search TO search_old;
DROP TABLE IF EXISTS `search`;
CREATE TABLE IF NOT EXISTS `search` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`itemid` CHAR(16) NOT NULL DEFAULT '' COLLATE utf8_bin,
`itemtype` VARCHAR(10) NOT NULL,
`content` LONGTEXT,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_search_id` (`id` ASC),
INDEX `idx_search_orgid` (`orgid` ASC),
INDEX `idx_search_documentid` (`documentid` ASC),
FULLTEXT INDEX `idx_search_content` (`content`))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
ENGINE = MyISAM;
-- migrate page content
INSERT INTO search (orgid, documentid, itemid, itemtype, content) SELECT orgid, documentid, id AS itemid, 'page' AS itemtype, TRIM(body) AS content FROM search_old;
-- index document title
INSERT INTO search (orgid, documentid, itemid, itemtype, content) SELECT orgid, refid AS documentid, '' AS itemid, 'doc' AS itemtype, TRIM(title) AS content FROM document;
-- index attachment name
INSERT INTO search (orgid, documentid, itemid, itemtype, content) SELECT orgid, documentid, refid AS itemid, 'file' AS itemtype, TRIM(filename) AS content FROM attachment;
-- insert tag 1
insert into search (orgid, documentid, itemid, itemtype, content) SELECT orgid, refid as documentid, '' as itemid, 'tag' as itemtype, TRIM(REPLACE(SUBSTRING_INDEX(tags, '#', 2), '#', '')) AS content FROM document WHERE tags != '';
-- insert tag 2
insert into search (orgid, documentid, itemid, itemtype, content) SELECT orgid, refid as documentid, '' as itemid, 'tag' as itemtype, IF((LENGTH(tags) - LENGTH(REPLACE(tags, '#', '')) - 1) > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(tags, '#', 3), '#', -1), '') AS content FROM document WHERE LENGTH(tags) - LENGTH(REPLACE(tags, "#", "")) > 2;
-- insert tag 3
insert into search (orgid, documentid, itemid, itemtype, content) SELECT orgid, refid as documentid, '' as itemid, 'tag' as itemtype, IF((LENGTH(tags) - LENGTH(REPLACE(tags, '#', '')) - 1) > 2, SUBSTRING_INDEX(SUBSTRING_INDEX(tags, '#', 4), '#', -1), '') AS content FROM document WHERE LENGTH(tags) - LENGTH(REPLACE(tags, "#", "")) > 3;

View file

@ -0,0 +1,143 @@
/* community edition */
-- permission records space and document level privelges, making existing labelrole table obsolete
-- who column can be user or role
-- whoid column contains eitehr user or role ID
-- action column records permission type (view, edit, delete...)
-- scope column details if action applies to object or table
-- location column details name of table
-- refid column details ID of item that the action applies to (only if scope=object)
DROP TABLE IF EXISTS `permission`;
CREATE TABLE IF NOT EXISTS `permission` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`who` VARCHAR(30) NOT NULL,
`whoid` CHAR(16) DEFAULT '' NOT NULL COLLATE utf8_bin,
`action` VARCHAR(30) NOT NULL,
`scope` VARCHAR(30) NOT NULL,
`location` VARCHAR(100) NOT NULL,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_permission_id` (`id` ASC),
INDEX `idx_permission_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
ENGINE = InnoDB;
CREATE INDEX idx_permission_1 ON permission(orgid,who,whoid,location);
CREATE INDEX idx_permission_2 ON permission(orgid,who,whoid,location,action);
CREATE INDEX idx_permission_3 ON permission(orgid,location,refid);
CREATE INDEX idx_permission_4 ON permission(orgid,who,location,action);
-- category represents "folder/label/category" assignment to document (1:M)
DROP TABLE IF EXISTS `category`;
CREATE TABLE IF NOT EXISTS `category` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`labelid` CHAR(16) NOT NULL COLLATE utf8_bin,
`category` VARCHAR(30) NOT NULL,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_category_id` (`id` ASC),
INDEX `idx_category_refid` (`refid` ASC),
INDEX `idx_category_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
ENGINE = InnoDB;
CREATE INDEX idx_category_1 ON category(orgid,labelid);
-- category member records who can see a category and the documents within
DROP TABLE IF EXISTS `categorymember`;
CREATE TABLE IF NOT EXISTS `categorymember` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`labelid` CHAR(16) NOT NULL COLLATE utf8_bin,
`categoryid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_categorymember_id` (`id` ASC),
INDEX `idx_category_documentid` (`documentid`))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
ENGINE = InnoDB;
CREATE INDEX idx_categorymember_1 ON categorymember(orgid,documentid);
CREATE INDEX idx_categorymember_2 ON categorymember(orgid,labelid);
-- rolee represent user groups
DROP TABLE IF EXISTS `role`;
CREATE TABLE IF NOT EXISTS `role` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`role` VARCHAR(30) NOT NULL,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_category_id` (`id` ASC),
INDEX `idx_category_refid` (`refid` ASC),
INDEX `idx_category_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
ENGINE = InnoDB;
-- role member records user role membership
DROP TABLE IF EXISTS `rolemember`;
CREATE TABLE IF NOT EXISTS `rolemember` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`roleid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin,
UNIQUE INDEX `idx_category_id` (`id` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
ENGINE = InnoDB;
CREATE INDEX idx_rolemember_1 ON rolemember(roleid,userid);
CREATE INDEX idx_rolemember_2 ON rolemember(orgid,roleid,userid);
-- user account can have global permssion to state if user can see all other users
-- provides granular control for external users
ALTER TABLE account ADD COLUMN `users` BOOL NOT NULL DEFAULT 1 AFTER `admin`;
-- migrate space/document permissions
-- space own
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'own' as `action`, 'object' as scope, 'space' as location, refid
FROM label;
-- space manage (same as owner)
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'manage' as `action`, 'object' as scope, 'space' as location, refid
FROM label;
-- view space
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'view' as `action`, 'object' as scope, 'space' as location, labelid as refid
FROM labelrole WHERE canview=1;
-- edit space => add/edit/delete/move/copy/template documents
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'doc-add' as `action`, 'object' as scope, 'space' as location, labelid as refid
FROM labelrole WHERE canedit=1;
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'doc-edit' as `action`, 'object' as scope, 'space' as location, labelid as refid
FROM labelrole WHERE canedit=1;
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'doc-delete' as `action`, 'object' as scope, 'space' as location, labelid as refid
FROM labelrole WHERE canedit=1;
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'doc-move' as `action`, 'object' as scope, 'space' as location, labelid as refid
FROM labelrole WHERE canedit=1;
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'doc-copy' as `action`, 'object' as scope, 'space' as location, labelid as refid
FROM labelrole WHERE canedit=1;
INSERT INTO permission (orgid, who, whoid, `action`, scope, location, refid)
SELECT orgid, 'user' as who, userid as whois, 'doc-template' as `action`, 'object' as scope, 'space' as location, labelid as refid
FROM labelrole WHERE canedit=1;
-- everyone users ID changed to 0
UPDATE permission SET whoid='0' WHERE whoid='';

View file

@ -0,0 +1,32 @@
/* enterprise edition */
-- document needs proection and approval columns
ALTER TABLE document ADD COLUMN `protection` INT NOT NULL DEFAULT 0 AFTER `template`;
ALTER TABLE document ADD COLUMN `approval` INT NOT NULL DEFAULT 0 AFTER `protection`;
-- page workflow status
ALTER TABLE page ADD COLUMN `status` INT NOT NULL DEFAULT 0 AFTER `revisions`;
-- links pending changes to another page
ALTER TABLE page ADD COLUMN `relativeid` CHAR(16) DEFAULT '' NOT NULL COLLATE utf8_bin AFTER `status`;
-- useraction captures what is being actioned
ALTER TABLE useraction ADD COLUMN `reftype` CHAR(1) DEFAULT 'D' NOT NULL COLLATE utf8_bin AFTER `iscomplete`;
ALTER TABLE useraction ADD COLUMN `reftypeid` CHAR(16) NOT NULL COLLATE utf8_bin AFTER `reftype`;
-- useractivity usage expansion
ALTER TABLE useractivity ADD COLUMN `documentid` CHAR(16) DEFAULT '' NOT NULL COLLATE utf8_bin AFTER `sourceid`;
ALTER TABLE useractivity ADD COLUMN `pageid` CHAR(16) DEFAULT '' NOT NULL COLLATE utf8_bin AFTER `documentid`;
UPDATE useractivity SET documentid=sourceid WHERE sourcetype=2;
ALTER TABLE useractivity DROP COLUMN `sourceid`;
CREATE INDEX idx_useractivity_1 ON useractivity(orgid,documentid,sourcetype);
CREATE INDEX idx_useractivity_2 ON useractivity(orgid,documentid,userid,sourcetype);
-- clean-up
DELETE FROM categorymember WHERE documentid NOT IN (SELECT refid FROM document);
UPDATE page SET level=1 WHERE level=0;
-- deprecations
DROP TABLE IF EXISTS `audit`;
DROP TABLE IF EXISTS `search_old`;
ALTER TABLE document DROP COLUMN `layout`;

View file

@ -0,0 +1,9 @@
/* community edition */
-- role and role membership
ALTER TABLE role ADD COLUMN `purpose` VARCHAR(100) DEFAULT '' NOT NULL AFTER `role`;
ALTER TABLE role ADD COLUMN `revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP AFTER `created`;
CREATE INDEX idx_role_1 ON role(orgid);
-- deprecations
DROP TABLE IF EXISTS `labelrole`;

View file

@ -0,0 +1,30 @@
/* enterprise edition */
-- document lifecycle and versioning
ALTER TABLE document ADD COLUMN `lifecycle` INT NOT NULL DEFAULT 1 AFTER `approval`;
ALTER TABLE document ADD COLUMN `versioned` INT NOT NULL DEFAULT 0 AFTER `lifecycle`;
ALTER TABLE document ADD COLUMN `versionid` VARCHAR(100) DEFAULT '' NOT NULL AFTER `versioned`;
ALTER TABLE document ADD COLUMN `versionorder` INT NOT NULL DEFAULT 0 AFTER `versionid`;
ALTER TABLE document ADD COLUMN `groupid` CHAR(16) NOT NULL COLLATE utf8_bin AFTER `versionorder`;
-- grant doc-lifecycle permission
INSERT INTO permission(orgid, who, whoid, action, scope, location, refid, created)
SELECT orgid, who, whoid, 'doc-lifecycle' AS action, scope, location, refid, created
FROM permission
WHERE action = 'doc-edit' OR action = 'doc-approve';
-- grant doc-versions permission
INSERT INTO permission(orgid, who, whoid, action, scope, location, refid, created)
SELECT orgid, who, whoid, 'doc-version' AS action, scope, location, refid, created
FROM permission
WHERE action = 'doc-edit' OR action = 'doc-approve';
-- implement document section name search indexing
INSERT INTO search (orgid, documentid, itemid, itemtype, content)
SELECT orgid, documentid, refid as itemid, "page" as itemtype, title as content
FROM page WHERE status=0;
-- whats new support
ALTER TABLE user ADD COLUMN `lastversion` CHAR(16) NOT NULL DEFAULT '' AFTER `active`;
-- deprecations

View file

@ -0,0 +1,18 @@
/* enterprise edition */
-- consistency of table engines
ALTER TABLE config ENGINE = InnoDB;
ALTER TABLE permission ENGINE = InnoDB;
ALTER TABLE category ENGINE = InnoDB;
ALTER TABLE categorymember ENGINE = InnoDB;
ALTER TABLE role ENGINE = InnoDB;
ALTER TABLE rolemember ENGINE = InnoDB;
-- content analytics
ALTER TABLE useractivity ADD COLUMN `metadata` VARCHAR(1000) NOT NULL DEFAULT '' AFTER `activitytype`;
-- new role for viewing content analytics
ALTER TABLE account ADD COLUMN `analytics` BOOL NOT NULL DEFAULT 0 AFTER `users`;
UPDATE account SET analytics=1 WHERE `admin`=1;
-- deprecations

View file

@ -0,0 +1,27 @@
/* community edition */
-- content likes/feedback
DROP TABLE IF EXISTS `vote`;
CREATE TABLE IF NOT EXISTS `vote` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`voter` CHAR(16) NOT NULL DEFAULT '' COLLATE utf8_bin,
`vote` INT NOT NULL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_vote_id` (`id` ASC),
INDEX `idx_vote_refid` (`refid` ASC),
INDEX `idx_vote_documentid` (`documentid` ASC),
INDEX `idx_vote_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci
ENGINE = InnoDB;
CREATE INDEX idx_vote_1 ON vote(orgid,documentid);
-- liking
ALTER TABLE label ADD COLUMN `likes` VARCHAR(1000) NOT NULL DEFAULT '' AFTER `type`;
-- deprecations

View file

@ -0,0 +1,6 @@
/* enterprise edition */
-- document lifecycle default option
ALTER TABLE label ADD COLUMN `lifecycle` INT NOT NULL DEFAULT 1 AFTER `type`;
-- deprecations

View file

@ -0,0 +1,7 @@
/* community edition */
-- improved search table
ALTER TABLE search ENGINE = InnoDB;
OPTIMIZE TABLE search;
-- deprecations

View file

@ -0,0 +1,10 @@
/* community edition */
-- max tags per document setting
ALTER TABLE organization ADD COLUMN `maxtags` INT NOT NULL DEFAULT 3 AFTER `authconfig`;
-- support for network location link types
ALTER TABLE link ADD COLUMN `externalid` NVARCHAR(1000) NOT NULL DEFAULT '' AFTER `targetid`;
-- deprecations
ALTER TABLE organization DROP COLUMN `url`;