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

utf8mb4, MariaDB, pluggable stiorage provider

Closes #109, #102, #74
This commit is contained in:
Harvey Kandola 2017-08-09 16:18:03 +01:00
parent db1af55c6c
commit 00c2d17fcb
20 changed files with 775 additions and 740 deletions

View file

@ -20,7 +20,7 @@ v1.51.0
- EmberJS (v2.14.0) - EmberJS (v2.14.0)
- Go (v1.8.3) - Go (v1.8.3)
- MySQL (v5.7.10+) or Percona (v5.7.16-10+) - MySQL (v5.7.10+) or Percona (v5.7.16-10+) or MariaDB (10.3.0+)
## Documentation ## Documentation

View file

@ -73,7 +73,7 @@ func Check(runtime *env.Runtime) bool {
// Check minimum MySQL version as we need JSON column type. // Check minimum MySQL version as we need JSON column type.
verInts := []int{5, 7, 10} // Minimum MySQL version verInts := []int{5, 7, 10} // Minimum MySQL version
if runtime.DbVariant == env.DBVariantMariaDB { if runtime.DbVariant == env.DBVariantMariaDB {
verInts = []int{10, 2, 0} // Minimum MariaDB version verInts = []int{10, 3, 0} // Minimum MariaDB version
} }
for k, v := range verInts { for k, v := range verInts {

View file

@ -2,10 +2,10 @@
## TODO ## TODO
1. Remove audit table 1. Remove audit table
2. Remove document.layout field 2. Remove document.layout field ?
## MYSQL ## MYSQL ENCODING
https://stackoverflow.com/questions/37307146/difference-between-utf8mb4-unicode-ci-and-utf8mb4-unicode-520-ci-collations-in-m https://stackoverflow.com/questions/37307146/difference-between-utf8mb4-unicode-ci-and-utf8mb4-unicode-520-ci-collations-in-m
@ -13,8 +13,9 @@ https://mathiasbynens.be/notes/mysql-utf8mb4
https://medium.com/@adamhooper/in-mysql-never-use-utf8-use-utf8mb4-11761243e434 https://medium.com/@adamhooper/in-mysql-never-use-utf8-use-utf8mb4-11761243e434
ALTER DATABASE documize CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER DATABASE documize CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE account CONVERT TO 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 attachment CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE block CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; ALTER TABLE block CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
@ -38,3 +39,6 @@ ALTER TABLE useractivity CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
ALTER TABLE userconfig 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; ALTER TABLE userevent CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
documenttitle, pagetitle, body
CHARACTER SET utf8mb4 COLLATE utf8mb4

View file

@ -5,19 +5,19 @@ DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` ( CREATE TABLE IF NOT EXISTS `user` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin, `refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`firstname` NVARCHAR(500) NOT NULL, `firstname` VARCHAR(500) NOT NULL,
`lastname` NVARCHAR(500) NOT NULL, `lastname` VARCHAR(500) NOT NULL,
`email` NVARCHAR(250) NOT NULL UNIQUE, `email` VARCHAR(250) NOT NULL UNIQUE,
`initials` NVARCHAR(10) NOT NULL DEFAULT "", `initials` VARCHAR(10) NOT NULL DEFAULT "",
`password` NVARCHAR(500) NOT NULL DEFAULT "", `password` VARCHAR(500) NOT NULL DEFAULT "",
`salt` NVARCHAR(100) NOT NULL DEFAULT "", `salt` VARCHAR(100) NOT NULL DEFAULT "",
`reset` NVARCHAR(100) NOT NULL DEFAULT "", `reset` VARCHAR(100) NOT NULL DEFAULT "",
`active` BOOL NOT NULL DEFAULT 1, `active` BOOL NOT NULL DEFAULT 1,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_refid PRIMARY KEY (refid), CONSTRAINT pk_refid PRIMARY KEY (refid),
UNIQUE INDEX `idx_user_id` (`id` ASC)) UNIQUE INDEX `idx_user_id` (`id` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `audit`; DROP TABLE IF EXISTS `audit`;
@ -28,11 +28,11 @@ CREATE TABLE IF NOT EXISTS `audit` (
`userid` CHAR(16) NOT NULL COLLATE utf8_bin, `userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin, `documentid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin,
`pageid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin, `pageid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin,
`action` NVARCHAR(200) NOT NULL DEFAULT "", `action` VARCHAR(200) NOT NULL DEFAULT "",
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE INDEX `idx_audit_id` (`id` ASC), UNIQUE INDEX `idx_audit_id` (`id` ASC),
INDEX `idx_orgid_url` (`orgid`)) INDEX `idx_orgid_url` (`orgid`))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `organization`; DROP TABLE IF EXISTS `organization`;
@ -40,15 +40,15 @@ DROP TABLE IF EXISTS `organization`;
CREATE TABLE IF NOT EXISTS `organization` ( CREATE TABLE IF NOT EXISTS `organization` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin, `refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`company` NVARCHAR(500) NOT NULL, `company` VARCHAR(500) NOT NULL,
`title` NVARCHAR(500) NOT NULL, `title` VARCHAR(500) NOT NULL,
`message` NVARCHAR(500) NOT NULL, `message` VARCHAR(500) NOT NULL,
`url` NVARCHAR(200) NOT NULL DEFAULT "", `url` VARCHAR(200) NOT NULL DEFAULT "",
`domain` NVARCHAR(200) NOT NULL DEFAULT "", `domain` VARCHAR(200) NOT NULL DEFAULT "",
`email` NVARCHAR(500) NOT NULL DEFAULT "", `email` VARCHAR(500) NOT NULL DEFAULT "",
`allowanonymousaccess` BOOL NOT NULL DEFAULT 0, `allowanonymousaccess` BOOL NOT NULL DEFAULT 0,
`verified` BOOL NOT NULL DEFAULT 0, `verified` BOOL NOT NULL DEFAULT 0,
`serial` NVARCHAR(50) NOT NULL DEFAULT "", `serial` VARCHAR(50) NOT NULL DEFAULT "",
`active` BOOL NOT NULL DEFAULT 1, `active` BOOL NOT NULL DEFAULT 1,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
@ -56,7 +56,7 @@ CREATE TABLE IF NOT EXISTS `organization` (
UNIQUE INDEX `idx_organization_id` (`id` ASC), UNIQUE INDEX `idx_organization_id` (`id` ASC),
INDEX `idx_organization_url` (`url`), INDEX `idx_organization_url` (`url`),
INDEX `idx_organization_domain` (`domain`)) INDEX `idx_organization_domain` (`domain`))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `account`; DROP TABLE IF EXISTS `account`;
@ -74,7 +74,7 @@ CREATE TABLE IF NOT EXISTS `account` (
UNIQUE INDEX `idx_account_id` (`id` ASC), UNIQUE INDEX `idx_account_id` (`id` ASC),
INDEX `idx_account_userid` (`userid` ASC), INDEX `idx_account_userid` (`userid` ASC),
INDEX `idx_account_orgid` (`orgid` ASC)) INDEX `idx_account_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `label`; DROP TABLE IF EXISTS `label`;
@ -82,7 +82,7 @@ DROP TABLE IF EXISTS `label`;
CREATE TABLE IF NOT EXISTS `label` ( CREATE TABLE IF NOT EXISTS `label` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`refid` CHAR(16) NOT NULL COLLATE utf8_bin, `refid` CHAR(16) NOT NULL COLLATE utf8_bin,
`label` NVARCHAR(255) NOT NULL, `label` VARCHAR(255) NOT NULL,
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin, `orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin, `userid` CHAR(16) NOT NULL DEFAULT "" COLLATE utf8_bin,
`type` INT NOT NULL DEFAULT 1, `type` INT NOT NULL DEFAULT 1,
@ -92,7 +92,7 @@ CREATE TABLE IF NOT EXISTS `label` (
UNIQUE INDEX `idx_label_id` (`id` ASC), UNIQUE INDEX `idx_label_id` (`id` ASC),
INDEX `idx_label_userid` (`userid` ASC), INDEX `idx_label_userid` (`userid` ASC),
INDEX `idx_label_orgid` (`orgid` ASC)) INDEX `idx_label_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `labelrole`; DROP TABLE IF EXISTS `labelrole`;
@ -112,7 +112,7 @@ CREATE TABLE IF NOT EXISTS `labelrole` (
INDEX `idx_labelrole_userid` (`userid` ASC), INDEX `idx_labelrole_userid` (`userid` ASC),
INDEX `idx_labelrole_labelid` (`labelid` ASC), INDEX `idx_labelrole_labelid` (`labelid` ASC),
INDEX `idx_labelrole_orgid` (`orgid` ASC)) INDEX `idx_labelrole_orgid` (`orgid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `document`; DROP TABLE IF EXISTS `document`;
@ -124,11 +124,11 @@ CREATE TABLE IF NOT EXISTS `document` (
`labelid` CHAR(16) NOT NULL COLLATE utf8_bin, `labelid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin, `userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`job` CHAR(36) NOT NULL, `job` CHAR(36) NOT NULL,
`location` NVARCHAR(2000) NOT NULL, `location` VARCHAR(2000) NOT NULL,
`title` NVARCHAR(2000) NOT NULL, `title` VARCHAR(2000) NOT NULL,
`excerpt` NVARCHAR(2000) NOT NULL, `excerpt` VARCHAR(2000) NOT NULL,
`slug` NVARCHAR(2000) NOT NULL, `slug` VARCHAR(2000) NOT NULL,
`tags` NVARCHAR(1000) NOT NULL DEFAULT '', `tags` VARCHAR(1000) NOT NULL DEFAULT '',
`template` BOOL NOT NULL DEFAULT 0, `template` BOOL NOT NULL DEFAULT 0,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
@ -136,7 +136,7 @@ CREATE TABLE IF NOT EXISTS `document` (
UNIQUE INDEX `idx_document_id` (`id` ASC), UNIQUE INDEX `idx_document_id` (`id` ASC),
INDEX `idx_document_orgid` (`orgid` ASC), INDEX `idx_document_orgid` (`orgid` ASC),
INDEX `idx_document_labelid` (`labelid` ASC)) INDEX `idx_document_labelid` (`labelid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `page`; DROP TABLE IF EXISTS `page`;
@ -150,7 +150,7 @@ CREATE TABLE IF NOT EXISTS `page` (
`contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg', `contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg',
`level` INT UNSIGNED NOT NULL, `level` INT UNSIGNED NOT NULL,
`sequence` DOUBLE NOT NULL, `sequence` DOUBLE NOT NULL,
`title` NVARCHAR(2000) NOT NULL, `title` VARCHAR(2000) NOT NULL,
`body` LONGTEXT, `body` LONGTEXT,
`revisions` INT UNSIGNED NOT NULL, `revisions` INT UNSIGNED NOT NULL,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
@ -159,7 +159,7 @@ CREATE TABLE IF NOT EXISTS `page` (
UNIQUE INDEX `idx_page_id` (`id` ASC), UNIQUE INDEX `idx_page_id` (`id` ASC),
INDEX `idx_page_orgid` (`orgid` ASC), INDEX `idx_page_orgid` (`orgid` ASC),
INDEX `idx_page_documentid` (`documentid` ASC)) INDEX `idx_page_documentid` (`documentid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `pagemeta`; DROP TABLE IF EXISTS `pagemeta`;
@ -180,7 +180,7 @@ CREATE TABLE IF NOT EXISTS `pagemeta` (
INDEX `idx_pagemeta_pageid` (`pageid` ASC), INDEX `idx_pagemeta_pageid` (`pageid` ASC),
INDEX `idx_pagemeta_orgid` (`orgid` ASC), INDEX `idx_pagemeta_orgid` (`orgid` ASC),
INDEX `idx_pagemeta_documentid` (`documentid` ASC)) INDEX `idx_pagemeta_documentid` (`documentid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `attachment`; DROP TABLE IF EXISTS `attachment`;
@ -192,7 +192,7 @@ CREATE TABLE IF NOT EXISTS `attachment` (
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin, `documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`job` CHAR(36) NOT NULL, `job` CHAR(36) NOT NULL,
`fileid` CHAR(10) NOT NULL, `fileid` CHAR(10) NOT NULL,
`filename` NVARCHAR(255) NOT NULL, `filename` VARCHAR(255) NOT NULL,
`data` LONGBLOB, `data` LONGBLOB,
`extension` CHAR(6) NOT NULL, `extension` CHAR(6) NOT NULL,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
@ -202,7 +202,7 @@ CREATE TABLE IF NOT EXISTS `attachment` (
INDEX `idx_attachment_orgid` (`orgid` ASC), INDEX `idx_attachment_orgid` (`orgid` ASC),
INDEX `idx_attachment_documentid` (`documentid` ASC), INDEX `idx_attachment_documentid` (`documentid` ASC),
INDEX `idx_attachment_job_and_fileid` (`job`,`fileid` ASC)) INDEX `idx_attachment_job_and_fileid` (`job`,`fileid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `search`; DROP TABLE IF EXISTS `search`;
@ -213,9 +213,9 @@ CREATE TABLE IF NOT EXISTS `search` (
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin, `documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`level` INT UNSIGNED NOT NULL, `level` INT UNSIGNED NOT NULL,
`sequence` DOUBLE NOT NULL, `sequence` DOUBLE NOT NULL,
`documenttitle` NVARCHAR(2000) NOT NULL, `documenttitle` VARCHAR(2000) NOT NULL,
`pagetitle` NVARCHAR(2000) NOT NULL, `pagetitle` VARCHAR(2000) NOT NULL,
`slug` NVARCHAR(2000) NOT NULL, `slug` VARCHAR(2000) NOT NULL,
`body` LONGTEXT, `body` LONGTEXT,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
@ -224,7 +224,7 @@ CREATE TABLE IF NOT EXISTS `search` (
INDEX `idx_search_documentid` (`documentid` ASC), INDEX `idx_search_documentid` (`documentid` ASC),
INDEX `idx_search_sequence` (`sequence` ASC), INDEX `idx_search_sequence` (`sequence` ASC),
FULLTEXT(`pagetitle`,`body`)) FULLTEXT(`pagetitle`,`body`))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = MyISAM; ENGINE = MyISAM;
DROP TABLE IF EXISTS `revision`; DROP TABLE IF EXISTS `revision`;
@ -238,7 +238,7 @@ CREATE TABLE IF NOT EXISTS `revision` (
`pageid` CHAR(16) NOT NULL COLLATE utf8_bin, `pageid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) NOT NULL COLLATE utf8_bin, `userid` CHAR(16) NOT NULL COLLATE utf8_bin,
`contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg', `contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg',
`title` NVARCHAR(2000) NOT NULL, `title` VARCHAR(2000) NOT NULL,
`body` LONGTEXT, `body` LONGTEXT,
`rawbody` LONGBLOB, `rawbody` LONGBLOB,
`config` JSON, `config` JSON,
@ -249,7 +249,7 @@ CREATE TABLE IF NOT EXISTS `revision` (
INDEX `idx_revision_orgid` (`orgid` ASC), INDEX `idx_revision_orgid` (`orgid` ASC),
INDEX `idx_revision_documentid` (`documentid` ASC), INDEX `idx_revision_documentid` (`documentid` ASC),
INDEX `idx_revision_pageid` (`pageid` ASC)) INDEX `idx_revision_pageid` (`pageid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
DROP TABLE IF EXISTS `config`; DROP TABLE IF EXISTS `config`;
@ -258,7 +258,7 @@ CREATE TABLE IF NOT EXISTS `config` (
`key` CHAR(255) NOT NULL, `key` CHAR(255) NOT NULL,
`config` JSON, `config` JSON,
UNIQUE INDEX `idx_config_area` (`key` ASC)) UNIQUE INDEX `idx_config_area` (`key` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
INSERT INTO `config` VALUES ('SMTP','{\"userid\": \"\",\"password\": \"\",\"host\": \"\",\"port\": \"\",\"sender\": \"\"}'); INSERT INTO `config` VALUES ('SMTP','{\"userid\": \"\",\"password\": \"\",\"host\": \"\",\"port\": \"\",\"sender\": \"\"}');
INSERT INTO `config` VALUES ('FILEPLUGINS', INSERT INTO `config` VALUES ('FILEPLUGINS',
@ -275,5 +275,5 @@ CREATE TABLE IF NOT EXISTS `userconfig` (
`key` CHAR(255) NOT NULL, `key` CHAR(255) NOT NULL,
`config` JSON, `config` JSON,
UNIQUE INDEX `idx_userconfig_orguserkey` (`orgid`, `userid`, `key` ASC)) UNIQUE INDEX `idx_userconfig_orguserkey` (`orgid`, `userid`, `key` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;

View file

@ -6,13 +6,13 @@ CREATE TABLE IF NOT EXISTS `share` (
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin, `orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin, `documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin, `userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`email` NVARCHAR(250) NOT NULL DEFAULT '', `email` VARCHAR(250) NOT NULL DEFAULT '',
`message` NVARCHAR(500) NOT NULL DEFAULT '', `message` VARCHAR(500) NOT NULL DEFAULT '',
`viewed` VARCHAR(500) NOT NULL DEFAULT '', `viewed` VARCHAR(500) NOT NULL DEFAULT '',
`secret` VARCHAR(200) NOT NULL DEFAULT '', `secret` VARCHAR(200) NOT NULL DEFAULT '',
`expires` CHAR(16) DEFAULT '' COLLATE utf8_bin, `expires` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`active` BOOL NOT NULL DEFAULT 1, `active` BOOL NOT NULL DEFAULT 1,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id)) CONSTRAINT pk_id PRIMARY KEY (id))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;

View file

@ -7,9 +7,9 @@ CREATE TABLE IF NOT EXISTS `feedback` (
`orgid` CHAR(16) NOT NULL COLLATE utf8_bin, `orgid` CHAR(16) NOT NULL COLLATE utf8_bin,
`documentid` CHAR(16) NOT NULL COLLATE utf8_bin, `documentid` CHAR(16) NOT NULL COLLATE utf8_bin,
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin, `userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`email` NVARCHAR(250) NOT NULL DEFAULT '', `email` VARCHAR(250) NOT NULL DEFAULT '',
`feedback` LONGTEXT, `feedback` LONGTEXT,
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id)) CONSTRAINT pk_id PRIMARY KEY (id))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;

View file

@ -16,5 +16,5 @@ CREATE TABLE IF NOT EXISTS `link` (
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id)) CONSTRAINT pk_id PRIMARY KEY (id))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;

View file

@ -12,5 +12,5 @@ CREATE TABLE IF NOT EXISTS `participant` (
`created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `created` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id), CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_participant_documentid` (`documentid` ASC)) INDEX `idx_participant_documentid` (`documentid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;

View file

@ -14,5 +14,5 @@ CREATE TABLE IF NOT EXISTS `pin` (
`revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, `revised` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT pk_id PRIMARY KEY (id), CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_pin_userid` (`userid` ASC)) INDEX `idx_pin_userid` (`userid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;

View file

@ -9,9 +9,9 @@ CREATE TABLE IF NOT EXISTS `block` (
`userid` CHAR(16) DEFAULT '' COLLATE utf8_bin, `userid` CHAR(16) DEFAULT '' COLLATE utf8_bin,
`contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg', `contenttype` CHAR(20) NOT NULL DEFAULT 'wysiwyg',
`pagetype` CHAR(10) NOT NULL DEFAULT 'section', `pagetype` CHAR(10) NOT NULL DEFAULT 'section',
`title` NVARCHAR(2000) NOT NULL, `title` VARCHAR(2000) NOT NULL,
`body` LONGTEXT, `body` LONGTEXT,
`excerpt` NVARCHAR(2000) NOT NULL, `excerpt` VARCHAR(2000) NOT NULL,
`used` INT UNSIGNED NOT NULL, `used` INT UNSIGNED NOT NULL,
`rawbody` LONGBLOB, `rawbody` LONGBLOB,
`config` JSON, `config` JSON,
@ -21,7 +21,7 @@ CREATE TABLE IF NOT EXISTS `block` (
CONSTRAINT pk_id PRIMARY KEY (id), CONSTRAINT pk_id PRIMARY KEY (id),
INDEX `idx_block_refid` (`refid` ASC), INDEX `idx_block_refid` (`refid` ASC),
INDEX `idx_block_labelid` (`labelid` ASC)) INDEX `idx_block_labelid` (`labelid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
ALTER TABLE page ADD COLUMN `blockid` CHAR(16) NOT NULL DEFAULT '' COLLATE utf8_bin AFTER `pagetype`; ALTER TABLE page ADD COLUMN `blockid` CHAR(16) NOT NULL DEFAULT '' COLLATE utf8_bin AFTER `pagetype`;

View file

@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS `useractivity` (
INDEX `idx_activity_userid` (`userid` ASC), INDEX `idx_activity_userid` (`userid` ASC),
INDEX `idx_activity_sourceid` (`sourceid` ASC), INDEX `idx_activity_sourceid` (`sourceid` ASC),
INDEX `idx_activity_activitytype` (`activitytype` ASC)) INDEX `idx_activity_activitytype` (`activitytype` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
/* Note: /* Note:
* - this table replaces the soon-to-be-deprecated audit log table * - this table replaces the soon-to-be-deprecated audit log table
@ -84,7 +84,7 @@ CREATE TABLE IF NOT EXISTS `useraction` (
INDEX `idx_useraction_userid` (`userid` ASC), INDEX `idx_useraction_userid` (`userid` ASC),
INDEX `idx_useraction_documentid` (`documentid` ASC), INDEX `idx_useraction_documentid` (`documentid` ASC),
INDEX `idx_useraction_requestorid` (`requestorid` ASC)) INDEX `idx_useraction_requestorid` (`requestorid` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;
/* community edition */ /* community edition */

View file

@ -12,5 +12,5 @@ CREATE TABLE IF NOT EXISTS `userevent` (
INDEX `idx_userevent_orgid` (`orgid` ASC), INDEX `idx_userevent_orgid` (`orgid` ASC),
INDEX `idx_userevent_userid` (`userid` ASC), INDEX `idx_userevent_userid` (`userid` ASC),
INDEX `idx_userevent_eventtype` (`eventtype` ASC)) INDEX `idx_userevent_eventtype` (`eventtype` ASC))
DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin
ENGINE = InnoDB; ENGINE = InnoDB;

4
core/env/runtime.go vendored
View file

@ -45,4 +45,8 @@ const (
DBVariantPercona DbVariant = "Percona" DBVariantPercona DbVariant = "Percona"
// DBVariantMariaDB is MariaDB // DBVariantMariaDB is MariaDB
DBVariantMariaDB DbVariant = "MariaDB" DBVariantMariaDB DbVariant = "MariaDB"
// DBVariantMSSQL is Microsoft SQL Server
DBVariantMSSQL DbVariant = "MSSQL"
// DBVariantPostgreSQL is PostgreSQL
DBVariantPostgreSQL DbVariant = "PostgreSQL"
) )

View file

@ -279,10 +279,9 @@ func (s Scope) Documents(ctx domain.RequestContext, keywords string) (results []
} }
keywords = strings.TrimSpace(keywords) keywords = strings.TrimSpace(keywords)
// keywords = strings.ToLower(keywords)
if len(keywords) > 0 { if len(keywords) > 0 {
keywordQuery = "AND MATCH(pagetitle,body) AGAINST('" + keywords + "' in boolean mode)" keywordQuery = "AND MATCH(documenttitle,pagetitle,body) AGAINST('" + keywords + "' in boolean mode)"
} }
sql := `SELECT search.id, documentid, pagetitle, document.labelid, document.title as documenttitle, document.tags, sql := `SELECT search.id, documentid, pagetitle, document.labelid, document.title as documenttitle, document.tags,

50
edition/boot/mysql.go Normal file
View file

@ -0,0 +1,50 @@
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
//
// https://documize.com
// Package boot prepares runtime environment.
package boot
import (
"github.com/documize/community/core/env"
"github.com/documize/community/domain"
account "github.com/documize/community/domain/account/mysql"
activity "github.com/documize/community/domain/activity/mysql"
attachment "github.com/documize/community/domain/attachment/mysql"
audit "github.com/documize/community/domain/audit/mysql"
block "github.com/documize/community/domain/block/mysql"
doc "github.com/documize/community/domain/document/mysql"
link "github.com/documize/community/domain/link/mysql"
org "github.com/documize/community/domain/organization/mysql"
page "github.com/documize/community/domain/page/mysql"
pin "github.com/documize/community/domain/pin/mysql"
search "github.com/documize/community/domain/search/mysql"
setting "github.com/documize/community/domain/setting/mysql"
space "github.com/documize/community/domain/space/mysql"
user "github.com/documize/community/domain/user/mysql"
)
// StoreMySQL creates MySQL provider
func StoreMySQL(r *env.Runtime, s *domain.Store) {
s.Account = account.Scope{Runtime: r}
s.Activity = activity.Scope{Runtime: r}
s.Attachment = attachment.Scope{Runtime: r}
s.Audit = audit.Scope{Runtime: r}
s.Block = block.Scope{Runtime: r}
s.Document = doc.Scope{Runtime: r}
s.Link = link.Scope{Runtime: r}
s.Organization = org.Scope{Runtime: r}
s.Page = page.Scope{Runtime: r}
s.Pin = pin.Scope{Runtime: r}
s.Search = search.Scope{Runtime: r}
s.Setting = setting.Scope{Runtime: r}
s.Space = space.Scope{Runtime: r}
s.User = user.Scope{Runtime: r}
}

View file

@ -72,8 +72,6 @@ func InitRuntime(r *env.Runtime, s *domain.Store) bool {
r.Log.Error("unable to run database migration", err) r.Log.Error("unable to run database migration", err)
return false return false
} }
} else {
r.Log.Info("going into setup mode to prepare new database")
} }
} }

View file

@ -15,38 +15,19 @@ package boot
import ( import (
"github.com/documize/community/core/env" "github.com/documize/community/core/env"
"github.com/documize/community/domain" "github.com/documize/community/domain"
account "github.com/documize/community/domain/account/mysql"
activity "github.com/documize/community/domain/activity/mysql"
attachment "github.com/documize/community/domain/attachment/mysql"
audit "github.com/documize/community/domain/audit/mysql"
block "github.com/documize/community/domain/block/mysql"
doc "github.com/documize/community/domain/document/mysql"
link "github.com/documize/community/domain/link/mysql"
org "github.com/documize/community/domain/organization/mysql"
page "github.com/documize/community/domain/page/mysql"
pin "github.com/documize/community/domain/pin/mysql"
search "github.com/documize/community/domain/search/mysql"
setting "github.com/documize/community/domain/setting/mysql"
space "github.com/documize/community/domain/space/mysql"
user "github.com/documize/community/domain/user/mysql"
) )
// AttachStore selects database persistence layer // AttachStore selects database persistence layer
func AttachStore(r *env.Runtime, s *domain.Store) { func AttachStore(r *env.Runtime, s *domain.Store) {
s.Account = account.Scope{Runtime: r}
s.Activity = activity.Scope{Runtime: r} switch r.DbVariant {
s.Attachment = attachment.Scope{Runtime: r} case env.DbVariantMySQL, env.DBVariantPercona, env.DBVariantMariaDB:
s.Audit = audit.Scope{Runtime: r} StoreMySQL(r, s)
s.Block = block.Scope{Runtime: r} case env.DBVariantMSSQL:
s.Document = doc.Scope{Runtime: r} // todo
s.Link = link.Scope{Runtime: r} case env.DBVariantPostgreSQL:
s.Organization = org.Scope{Runtime: r} // todo
s.Page = page.Scope{Runtime: r} }
s.Pin = pin.Scope{Runtime: r}
s.Search = search.Scope{Runtime: r}
s.Setting = setting.Scope{Runtime: r}
s.Space = space.Scope{Runtime: r}
s.User = user.Scope{Runtime: r}
} }
// https://github.com/golang-sql/sqlexp/blob/c2488a8be21d20d31abf0d05c2735efd2d09afe4/quoter.go#L46 // https://github.com/golang-sql/sqlexp/blob/c2488a8be21d20d31abf0d05c2735efd2d09afe4/quoter.go#L46

File diff suppressed because one or more lines are too long

View file

@ -9,7 +9,7 @@
<div class="sidebar-wrapper"> <div class="sidebar-wrapper">
<div class="page-search"> <div class="page-search">
<div class="input-control"> <div class="input-control">
{{focus-input type="text" value=filter placeholder='search'}} {{focus-input type="text" value=filter placeholder='type search phrase (case sensitive)'}}
</div> </div>
</div> </div>
</div> </div>

View file

@ -31,12 +31,6 @@ var testHost string // used during automated testing
// Start router to handle all HTTP traffic. // Start router to handle all HTTP traffic.
func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) { func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
err := plugins.Setup(s)
if err != nil {
rt.Log.Error("Terminating before running - invalid plugin.json", err)
os.Exit(1)
}
rt.Log.Info(fmt.Sprintf("Starting %s version %s", rt.Product.Title, rt.Product.Version)) rt.Log.Info(fmt.Sprintf("Starting %s version %s", rt.Product.Title, rt.Product.Version))
// decide which mode to serve up // decide which mode to serve up
@ -50,6 +44,11 @@ func Start(rt *env.Runtime, s *domain.Store, ready chan struct{}) {
case env.SiteModeBadDB: case env.SiteModeBadDB:
rt.Log.Info("Serving BAD DATABASE web server") rt.Log.Info("Serving BAD DATABASE web server")
default: default:
err := plugins.Setup(s)
if err != nil {
rt.Log.Error("Terminating before running - invalid plugin.json", err)
os.Exit(1)
}
rt.Log.Info("Starting web server") rt.Log.Info("Starting web server")
} }