Back to utf8mb4...

master
andryyy 2016-12-19 12:24:31 +01:00
parent 1cad07dc5c
commit 98e803e6ef
4 changed files with 158 additions and 152 deletions

View File

@ -1,14 +1,14 @@
[mysqld] [mysqld]
character-set-client-handshake = FALSE character-set-client-handshake = FALSE
character-set-server = utf8 character-set-server = utf8mb4
collation-server = utf8_unicode_ci collation-server = utf8mb4_unicode_ci
#innodb_file_per_table = TRUE innodb_file_per_table = TRUE
#innodb_file_format = barracuda innodb_file_format = barracuda
#innodb_large_prefix = TRUE innodb_large_prefix = TRUE
#sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION #sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
[client] [client]
default-character-set = utf8 default-character-set = utf8mb4
[mysql] [mysql]
default-character-set = utf8 default-character-set = utf8mb4

View File

@ -54,6 +54,7 @@
SOGoTrashFolderName = "Trash"; SOGoTrashFolderName = "Trash";
SOGoVacationEnabled = YES; SOGoVacationEnabled = YES;
MySQL4Encoding = "utf8mb4";
//SOGoDebugRequests = YES; //SOGoDebugRequests = YES;
//SoDebugBaseURL = YES; //SoDebugBaseURL = YES;
//ImapDebugEnabled = YES; //ImapDebugEnabled = YES;

View File

@ -51,6 +51,12 @@ function init_db_schema() {
$data = ''; $data = '';
} }
} }
$stmt = $pdo->query("SHOW INDEX FROM sogo_acl WHERE KEY_NAME = 'sogo_acl_c_folder_id_idx'");
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
if ($num_results == 0) {
$pdo->query("CREATE INDEX sogo_acl_c_folder_id_idx ON sogo_acl(c_folder_id)");
$pdo->query("CREATE INDEX sogo_acl_c_uid_idx ON sogo_acl(c_uid)");
}
$_SESSION['return'] = array( $_SESSION['return'] = array(
'type' => 'success', 'type' => 'success',
'msg' => 'Database initialization completed.' 'msg' => 'Database initialization completed.'

View File

@ -1,103 +1,103 @@
CREATE TABLE IF NOT EXISTS `admin` ( CREATE TABLE IF NOT EXISTS `admin` (
`username` varchar(255) NOT NULL, `username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL, `password` varchar(255) NOT NULL,
`superadmin` tinyint(1) NOT NULL DEFAULT '0', `superadmin` tinyint(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`active` tinyint(1) NOT NULL DEFAULT '1', `active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`username`) PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `alias` ( CREATE TABLE IF NOT EXISTS `alias` (
`address` varchar(255) NOT NULL, `address` varchar(255) NOT NULL,
`goto` text NOT NULL, `goto` text NOT NULL,
`domain` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL,
`created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`active` tinyint(1) NOT NULL DEFAULT '1', `active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`address`), PRIMARY KEY (`address`),
KEY `domain` (`domain`) KEY `domain` (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `sender_acl` ( CREATE TABLE IF NOT EXISTS `sender_acl` (
`logged_in_as` varchar(255) NOT NULL, `logged_in_as` varchar(255) NOT NULL,
`send_as` varchar(255) NOT NULL `send_as` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `spamalias` ( CREATE TABLE IF NOT EXISTS `spamalias` (
`address` varchar(255) NOT NULL, `address` varchar(255) NOT NULL,
`goto` text NOT NULL, `goto` text NOT NULL,
`validity` int(11) NOT NULL, `validity` int(11) NOT NULL,
PRIMARY KEY (`address`) PRIMARY KEY (`address`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `alias_domain` ( CREATE TABLE IF NOT EXISTS `alias_domain` (
`alias_domain` varchar(255) NOT NULL, `alias_domain` varchar(255) NOT NULL,
`target_domain` varchar(255) NOT NULL, `target_domain` varchar(255) NOT NULL,
`created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`active` tinyint(1) NOT NULL DEFAULT '1', `active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`alias_domain`), PRIMARY KEY (`alias_domain`),
KEY `active` (`active`), KEY `active` (`active`),
KEY `target_domain` (`target_domain`) KEY `target_domain` (`target_domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `domain` ( CREATE TABLE IF NOT EXISTS `domain` (
`domain` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL,
`description` varchar(255), `description` varchar(255),
`aliases` int(10) NOT NULL DEFAULT '0', `aliases` int(10) NOT NULL DEFAULT '0',
`mailboxes` int(10) NOT NULL DEFAULT '0', `mailboxes` int(10) NOT NULL DEFAULT '0',
`maxquota` bigint(20) NOT NULL DEFAULT '0', `maxquota` bigint(20) NOT NULL DEFAULT '0',
`quota` bigint(20) NOT NULL DEFAULT '0', `quota` bigint(20) NOT NULL DEFAULT '0',
`transport` varchar(255) NOT NULL, `transport` varchar(255) NOT NULL,
`backupmx` tinyint(1) NOT NULL DEFAULT '0', `backupmx` tinyint(1) NOT NULL DEFAULT '0',
`relay_all_recipients` tinyint(1) NOT NULL DEFAULT '0', `relay_all_recipients` tinyint(1) NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`active` tinyint(1) NOT NULL DEFAULT '1', `active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`domain`) PRIMARY KEY (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `domain_admins` ( CREATE TABLE IF NOT EXISTS `domain_admins` (
`username` varchar(255) NOT NULL, `username` varchar(255) NOT NULL,
`domain` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL,
`created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`active` tinyint(1) NOT NULL DEFAULT '1', `active` tinyint(1) NOT NULL DEFAULT '1',
KEY `username` (`username`) KEY `username` (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `mailbox` ( CREATE TABLE IF NOT EXISTS `mailbox` (
`username` varchar(255) NOT NULL, `username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL, `password` varchar(255) NOT NULL,
`name` varchar(255), `name` varchar(255),
`maildir` varchar(255) NOT NULL, `maildir` varchar(255) NOT NULL,
`quota` bigint(20) NOT NULL DEFAULT '0', `quota` bigint(20) NOT NULL DEFAULT '0',
`local_part` varchar(255) NOT NULL, `local_part` varchar(255) NOT NULL,
`domain` varchar(255) NOT NULL, `domain` varchar(255) NOT NULL,
`created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2016-01-01 00:00:00',
`tls_enforce_in` tinyint(1) NOT NULL DEFAULT '0', `tls_enforce_in` tinyint(1) NOT NULL DEFAULT '0',
`tls_enforce_out` tinyint(1) NOT NULL DEFAULT '0', `tls_enforce_out` tinyint(1) NOT NULL DEFAULT '0',
`active` tinyint(1) NOT NULL DEFAULT '1', `active` tinyint(1) NOT NULL DEFAULT '1',
PRIMARY KEY (`username`), PRIMARY KEY (`username`),
KEY `domain` (`domain`) KEY `domain` (`domain`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `quota2` ( CREATE TABLE IF NOT EXISTS `quota2` (
`username` varchar(100) NOT NULL, `username` varchar(100) NOT NULL,
`bytes` bigint(20) NOT NULL DEFAULT '0', `bytes` bigint(20) NOT NULL DEFAULT '0',
`messages` int(11) NOT NULL DEFAULT '0', `messages` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`username`) PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS `filterconf` ( CREATE TABLE IF NOT EXISTS `filterconf` (
`object` varchar(100) NOT NULL DEFAULT '', `object` varchar(100) NOT NULL DEFAULT '',
`option` varchar(50) NOT NULL DEFAULT '', `option` varchar(50) NOT NULL DEFAULT '',
`value` varchar(100) NOT NULL DEFAULT '', `value` varchar(100) NOT NULL DEFAULT '',
`prefid` int(11) NOT NULL AUTO_INCREMENT, `prefid` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`prefid`), PRIMARY KEY (`prefid`),
KEY `object` (`object`) KEY `object` (`object`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
DROP VIEW IF EXISTS grouped_mail_aliases; DROP VIEW IF EXISTS grouped_mail_aliases;
DROP VIEW IF EXISTS grouped_sender_acl; DROP VIEW IF EXISTS grouped_sender_acl;
@ -129,13 +129,11 @@ LEFT OUTER JOIN grouped_domain_alias_address gda ON gda.username = mailbox.usern
WHERE mailbox.active = '1'; WHERE mailbox.active = '1';
CREATE TABLE IF NOT EXISTS sogo_acl ( CREATE TABLE IF NOT EXISTS sogo_acl (
c_folder_id int(11) NOT NULL, c_folder_id integer NOT NULL,
c_object varchar(255) NOT NULL, c_object character varying(255) NOT NULL,
c_uid varchar(255) NOT NULL, c_uid character varying(255) NOT NULL,
c_role varchar(80) NOT NULL, c_role character varying(80) NOT NULL
KEY sogo_acl_c_folder_id_idx (c_folder_id), ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
KEY sogo_acl_c_uid_idx (c_uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS sogo_alarms_folder ( CREATE TABLE IF NOT EXISTS sogo_alarms_folder (
c_path varchar(255) NOT NULL, c_path varchar(255) NOT NULL,
@ -144,7 +142,7 @@ CREATE TABLE IF NOT EXISTS sogo_alarms_folder (
c_recurrence_id int(11) DEFAULT NULL, c_recurrence_id int(11) DEFAULT NULL,
c_alarm_number int(11) NOT NULL, c_alarm_number int(11) NOT NULL,
c_alarm_date int(11) NOT NULL c_alarm_date int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS sogo_cache_folder ( CREATE TABLE IF NOT EXISTS sogo_cache_folder (
c_uid varchar(255) NOT NULL, c_uid varchar(255) NOT NULL,
@ -157,7 +155,7 @@ CREATE TABLE IF NOT EXISTS sogo_cache_folder (
c_deleted tinyint(4) NOT NULL DEFAULT '0', c_deleted tinyint(4) NOT NULL DEFAULT '0',
c_content longtext, c_content longtext,
PRIMARY KEY (c_uid,c_path) PRIMARY KEY (c_uid,c_path)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS sogo_folder_info ( CREATE TABLE IF NOT EXISTS sogo_folder_info (
c_folder_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, c_folder_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
@ -167,58 +165,58 @@ CREATE TABLE IF NOT EXISTS sogo_folder_info (
c_path3 varchar(255) DEFAULT NULL, c_path3 varchar(255) DEFAULT NULL,
c_path4 varchar(255) DEFAULT NULL, c_path4 varchar(255) DEFAULT NULL,
c_foldername varchar(255) NOT NULL, c_foldername varchar(255) NOT NULL,
c_location varchar(2048) DEFAULT NULL, c_location integer NULL,
c_quick_location varchar(2048) DEFAULT NULL, c_quick_location varchar(2048) DEFAULT NULL,
c_acl_location varchar(2048) DEFAULT NULL, c_acl_location varchar(2048) DEFAULT NULL,
c_folder_type varchar(255) NOT NULL, c_folder_type varchar(255) NOT NULL,
PRIMARY KEY (c_path), PRIMARY KEY (c_path),
UNIQUE KEY c_folder_id (c_folder_id) UNIQUE KEY c_folder_id (c_folder_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS sogo_quick_appointment ( CREATE TABLE IF NOT EXISTS sogo_quick_appointment (
c_folder_id int(11) NOT NULL, c_folder_id integer NOT NULL,
c_name varchar(255) NOT NULL, c_name character varying(255) NOT NULL,
c_uid varchar(255) NOT NULL, c_uid character varying(255) NOT NULL,
c_startdate int(11) DEFAULT NULL, c_startdate integer,
c_enddate int(11) DEFAULT NULL, c_enddate integer,
c_cycleenddate int(11) DEFAULT NULL, c_cycleenddate integer,
c_title varchar(1000) NOT NULL, c_title character varying(1000) NOT NULL,
c_participants text, c_participants text,
c_isallday int(11) DEFAULT NULL, c_isallday integer,
c_iscycle int(11) DEFAULT NULL, c_iscycle integer,
c_cycleinfo text, c_cycleinfo text,
c_classification int(11) NOT NULL, c_classification integer NOT NULL,
c_isopaque int(11) NOT NULL, c_isopaque integer NOT NULL,
c_status int(11) NOT NULL, c_status integer NOT NULL,
c_priority int(11) DEFAULT NULL, c_priority integer,
c_location varchar(255) DEFAULT NULL, c_location character varying(255),
c_orgmail varchar(255) DEFAULT NULL, c_orgmail character varying(255),
c_partmails text, c_partmails text,
c_partstates text, c_partstates text,
c_category varchar(255) DEFAULT NULL, c_category character varying(255),
c_sequence int(11) DEFAULT NULL, c_sequence integer,
c_component varchar(10) NOT NULL, c_component character varying(10) NOT NULL,
c_nextalarm int(11) DEFAULT NULL, c_nextalarm integer,
c_description text, c_description text,
PRIMARY KEY (c_folder_id,c_name) CONSTRAINT sogo_quick_appointment_pkey PRIMARY KEY (c_folder_id, c_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS sogo_quick_contact ( CREATE TABLE IF NOT EXISTS sogo_quick_contact (
c_folder_id int(11) NOT NULL, c_folder_id integer NOT NULL,
c_name varchar(255) NOT NULL, c_name character varying(255) NOT NULL,
c_givenname varchar(255) DEFAULT NULL, c_givenname character varying(255),
c_cn varchar(255) DEFAULT NULL, c_cn character varying(255),
c_sn varchar(255) DEFAULT NULL, c_sn character varying(255),
c_screenname varchar(255) DEFAULT NULL, c_screenname character varying(255),
c_l varchar(255) DEFAULT NULL, c_l character varying(255),
c_mail varchar(255) DEFAULT NULL, c_mail character varying(255),
c_o varchar(255) DEFAULT NULL, c_o character varying(255),
c_ou varchar(255) DEFAULT NULL, c_ou character varying(255),
c_telephonenumber varchar(255) DEFAULT NULL, c_telephonenumber character varying(255),
c_categories varchar(255) DEFAULT NULL, c_categories character varying(255),
c_component varchar(10) NOT NULL, c_component character varying(10) NOT NULL,
PRIMARY KEY (c_folder_id,c_name) CONSTRAINT sogo_quick_contact_pkey PRIMARY KEY (c_folder_id, c_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS sogo_sessions_folder ( CREATE TABLE IF NOT EXISTS sogo_sessions_folder (
c_id varchar(255) NOT NULL, c_id varchar(255) NOT NULL,
@ -226,25 +224,26 @@ CREATE TABLE IF NOT EXISTS sogo_sessions_folder (
c_creationdate int(11) NOT NULL, c_creationdate int(11) NOT NULL,
c_lastseen int(11) NOT NULL, c_lastseen int(11) NOT NULL,
PRIMARY KEY (c_id) PRIMARY KEY (c_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS sogo_store ( CREATE TABLE IF NOT EXISTS sogo_store (
c_folder_id int(11) NOT NULL, c_folder_id integer NOT NULL,
c_name varchar(255) NOT NULL DEFAULT '', c_name character varying(255) NOT NULL,
c_content mediumtext NOT NULL, c_content mediumtext NOT NULL,
c_creationdate int(11) NOT NULL, c_creationdate integer NOT NULL,
c_lastmodified int(11) NOT NULL, c_lastmodified integer NOT NULL,
c_version int(11) NOT NULL, c_version integer NOT NULL,
c_deleted int(11) DEFAULT NULL, c_deleted integer,
PRIMARY KEY (c_folder_id,c_name) CONSTRAINT sogo_store_pkey PRIMARY KEY (c_folder_id, c_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
CREATE TABLE IF NOT EXISTS sogo_user_profile ( CREATE TABLE IF NOT EXISTS sogo_user_profile (
c_uid varchar(255) NOT NULL, c_uid varchar(255) NOT NULL,
c_defaults text, c_defaults text,
c_settings text, c_settings text,
PRIMARY KEY (c_uid) PRIMARY KEY (c_uid)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;
INSERT INTO admin (username, password, superadmin, created, modified, active) VALUES ('admin', '{SSHA256}K8eVJ6YsZbQCfuJvSUbaQRLr0HPLz5rC9IAp0PAFl0tmNDBkMDc0NDAyOTAxN2Rk', 1, NOW(), NOW(), 1); REPLACE INTO admin (username, password, superadmin, created, modified, active) VALUES ('admin', '{SSHA256}K8eVJ6YsZbQCfuJvSUbaQRLr0HPLz5rC9IAp0PAFl0tmNDBkMDc0NDAyOTAxN2Rk', 1, NOW(), NOW(), 1);
DELETE FROM domain_admins WHERE domain='all';
INSERT INTO domain_admins (username, domain, created, active) VALUES ('admin', 'ALL', NOW(), 1); INSERT INTO domain_admins (username, domain, created, active) VALUES ('admin', 'ALL', NOW(), 1);