Merge pull request #3341 from annando/issue-3326

Always use utf8mb4 from now on
This commit is contained in:
Hypolite Petovan 2017-04-15 01:58:18 -04:00 committed by GitHub
commit 25d70c39c6
4 changed files with 120 additions and 95 deletions

View file

@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.5.2-dev' ); define ( 'FRIENDICA_VERSION', '3.5.2-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1217 ); define ( 'DB_UPDATE_VERSION', 1218 );
/** /**
* @brief Constant with a HTML line break. * @brief Constant with a HTML line break.

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 3.5.2-dev (Asparagus) -- Friendica 3.5.2-dev (Asparagus)
-- DB_UPDATE_VERSION 1215 -- DB_UPDATE_VERSION 1218
-- ------------------------------------------ -- ------------------------------------------
@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS `addon` (
`plugin_admin` tinyint(1) NOT NULL DEFAULT 0, `plugin_admin` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `name` (`name`) UNIQUE INDEX `name` (`name`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE attach -- TABLE attach
@ -37,7 +37,7 @@ CREATE TABLE IF NOT EXISTS `attach` (
`deny_cid` mediumtext, `deny_cid` mediumtext,
`deny_gid` mediumtext, `deny_gid` mediumtext,
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE auth_codes -- TABLE auth_codes
@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS `auth_codes` (
`expires` int(11) NOT NULL DEFAULT 0, `expires` int(11) NOT NULL DEFAULT 0,
`scope` varchar(250) NOT NULL DEFAULT '', `scope` varchar(250) NOT NULL DEFAULT '',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE cache -- TABLE cache
@ -61,7 +61,7 @@ CREATE TABLE IF NOT EXISTS `cache` (
`updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `updated` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`k`), PRIMARY KEY(`k`),
INDEX `expire_mode_updated` (`expire_mode`,`updated`) INDEX `expire_mode_updated` (`expire_mode`,`updated`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE challenge -- TABLE challenge
@ -74,7 +74,7 @@ CREATE TABLE IF NOT EXISTS `challenge` (
`type` varchar(255) NOT NULL DEFAULT '', `type` varchar(255) NOT NULL DEFAULT '',
`last_update` varchar(255) NOT NULL DEFAULT '', `last_update` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE clients -- TABLE clients
@ -87,7 +87,7 @@ CREATE TABLE IF NOT EXISTS `clients` (
`icon` text, `icon` text,
`uid` int(11) NOT NULL DEFAULT 0, `uid` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY(`client_id`) PRIMARY KEY(`client_id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE config -- TABLE config
@ -99,7 +99,7 @@ CREATE TABLE IF NOT EXISTS `config` (
`v` mediumtext, `v` mediumtext,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `cat_k` (`cat`,`k`) UNIQUE INDEX `cat_k` (`cat`,`k`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE contact -- TABLE contact
@ -186,7 +186,7 @@ CREATE TABLE IF NOT EXISTS `contact` (
INDEX `nick_uid` (`nick`(32),`uid`), INDEX `nick_uid` (`nick`(32),`uid`),
INDEX `dfrn-id` (`dfrn-id`), INDEX `dfrn-id` (`dfrn-id`),
INDEX `issued-id` (`issued-id`) INDEX `issued-id` (`issued-id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE conv -- TABLE conv
@ -202,7 +202,7 @@ CREATE TABLE IF NOT EXISTS `conv` (
`subject` text, `subject` text,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid` (`uid`) INDEX `uid` (`uid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE event -- TABLE event
@ -230,7 +230,7 @@ CREATE TABLE IF NOT EXISTS `event` (
`deny_gid` mediumtext, `deny_gid` mediumtext,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid_start` (`uid`,`start`) INDEX `uid_start` (`uid`,`start`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE fcontact -- TABLE fcontact
@ -256,7 +256,7 @@ CREATE TABLE IF NOT EXISTS `fcontact` (
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `addr` (`addr`(32)), INDEX `addr` (`addr`(32)),
INDEX `url` (`url`) INDEX `url` (`url`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE ffinder -- TABLE ffinder
@ -267,7 +267,7 @@ CREATE TABLE IF NOT EXISTS `ffinder` (
`cid` int(10) unsigned NOT NULL DEFAULT 0, `cid` int(10) unsigned NOT NULL DEFAULT 0,
`fid` int(10) unsigned NOT NULL DEFAULT 0, `fid` int(10) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE fserver -- TABLE fserver
@ -279,7 +279,7 @@ CREATE TABLE IF NOT EXISTS `fserver` (
`key` text, `key` text,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `server` (`server`(32)) INDEX `server` (`server`(32))
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE fsuggest -- TABLE fsuggest
@ -295,7 +295,7 @@ CREATE TABLE IF NOT EXISTS `fsuggest` (
`note` text, `note` text,
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE gcign -- TABLE gcign
@ -307,7 +307,7 @@ CREATE TABLE IF NOT EXISTS `gcign` (
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid` (`uid`), INDEX `uid` (`uid`),
INDEX `gcid` (`gcid`) INDEX `gcid` (`gcid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE gcontact -- TABLE gcontact
@ -346,7 +346,7 @@ CREATE TABLE IF NOT EXISTS `gcontact` (
INDEX `addr` (`addr`(64)), INDEX `addr` (`addr`(64)),
INDEX `hide_network_updated` (`hide`,`network`,`updated`), INDEX `hide_network_updated` (`hide`,`network`,`updated`),
INDEX `updated` (`updated`) INDEX `updated` (`updated`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE glink -- TABLE glink
@ -361,7 +361,7 @@ CREATE TABLE IF NOT EXISTS `glink` (
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`), UNIQUE INDEX `cid_uid_gcid_zcid` (`cid`,`uid`,`gcid`,`zcid`),
INDEX `gcid` (`gcid`) INDEX `gcid` (`gcid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE group -- TABLE group
@ -374,7 +374,7 @@ CREATE TABLE IF NOT EXISTS `group` (
`name` varchar(255) NOT NULL DEFAULT '', `name` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid` (`uid`) INDEX `uid` (`uid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE group_member -- TABLE group_member
@ -388,7 +388,7 @@ CREATE TABLE IF NOT EXISTS `group_member` (
INDEX `contactid` (`contact-id`), INDEX `contactid` (`contact-id`),
INDEX `gid_contactid` (`gid`,`contact-id`), INDEX `gid_contactid` (`gid`,`contact-id`),
UNIQUE INDEX `uid_gid_contactid` (`uid`,`gid`,`contact-id`) UNIQUE INDEX `uid_gid_contactid` (`uid`,`gid`,`contact-id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE gserver -- TABLE gserver
@ -411,7 +411,7 @@ CREATE TABLE IF NOT EXISTS `gserver` (
`last_failure` datetime DEFAULT '0001-01-01 00:00:00', `last_failure` datetime DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `nurl` (`nurl`(32)) INDEX `nurl` (`nurl`(32))
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE hook -- TABLE hook
@ -424,7 +424,7 @@ CREATE TABLE IF NOT EXISTS `hook` (
`priority` int(11) unsigned NOT NULL DEFAULT 0, `priority` int(11) unsigned NOT NULL DEFAULT 0,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `hook_file_function` (`hook`(50),`file`(80),`function`(60)) UNIQUE INDEX `hook_file_function` (`hook`(50),`file`(80),`function`(60))
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE intro -- TABLE intro
@ -442,7 +442,7 @@ CREATE TABLE IF NOT EXISTS `intro` (
`blocked` tinyint(1) NOT NULL DEFAULT 1, `blocked` tinyint(1) NOT NULL DEFAULT 1,
`ignore` tinyint(1) NOT NULL DEFAULT 0, `ignore` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE item -- TABLE item
@ -539,7 +539,7 @@ CREATE TABLE IF NOT EXISTS `item` (
INDEX `uid_eventid` (`uid`,`event-id`), INDEX `uid_eventid` (`uid`,`event-id`),
INDEX `uid_authorlink` (`uid`,`author-link`), INDEX `uid_authorlink` (`uid`,`author-link`),
INDEX `uid_ownerlink` (`uid`,`owner-link`) INDEX `uid_ownerlink` (`uid`,`owner-link`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE item_id -- TABLE item_id
@ -555,7 +555,7 @@ CREATE TABLE IF NOT EXISTS `item_id` (
INDEX `sid` (`sid`), INDEX `sid` (`sid`),
INDEX `service` (`service`(32)), INDEX `service` (`service`(32)),
INDEX `iid` (`iid`) INDEX `iid` (`iid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE locks -- TABLE locks
@ -566,7 +566,7 @@ CREATE TABLE IF NOT EXISTS `locks` (
`locked` tinyint(1) NOT NULL DEFAULT 0, `locked` tinyint(1) NOT NULL DEFAULT 0,
`created` datetime DEFAULT '0001-01-01 00:00:00', `created` datetime DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE mail -- TABLE mail
@ -594,7 +594,7 @@ CREATE TABLE IF NOT EXISTS `mail` (
INDEX `convid` (`convid`), INDEX `convid` (`convid`),
INDEX `uri` (`uri`(64)), INDEX `uri` (`uri`(64)),
INDEX `parent-uri` (`parent-uri`(64)) INDEX `parent-uri` (`parent-uri`(64))
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE mailacct -- TABLE mailacct
@ -614,7 +614,7 @@ CREATE TABLE IF NOT EXISTS `mailacct` (
`pubmail` tinyint(1) NOT NULL DEFAULT 0, `pubmail` tinyint(1) NOT NULL DEFAULT 0,
`last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `last_check` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE manage -- TABLE manage
@ -625,7 +625,7 @@ CREATE TABLE IF NOT EXISTS `manage` (
`mid` int(11) NOT NULL DEFAULT 0, `mid` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `uid_mid` (`uid`,`mid`) UNIQUE INDEX `uid_mid` (`uid`,`mid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE notify -- TABLE notify
@ -653,7 +653,7 @@ CREATE TABLE IF NOT EXISTS `notify` (
INDEX `seen_uid_date` (`seen`,`uid`,`date`), INDEX `seen_uid_date` (`seen`,`uid`,`date`),
INDEX `uid_date` (`uid`,`date`), INDEX `uid_date` (`uid`,`date`),
INDEX `uid_type_link` (`uid`,`type`,`link`) INDEX `uid_type_link` (`uid`,`type`,`link`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE notify-threads -- TABLE notify-threads
@ -665,7 +665,7 @@ CREATE TABLE IF NOT EXISTS `notify-threads` (
`parent-item` int(10) unsigned NOT NULL DEFAULT 0, `parent-item` int(10) unsigned NOT NULL DEFAULT 0,
`receiver-uid` int(11) NOT NULL DEFAULT 0, `receiver-uid` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE oembed -- TABLE oembed
@ -676,7 +676,7 @@ CREATE TABLE IF NOT EXISTS `oembed` (
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`url`), PRIMARY KEY(`url`),
INDEX `created` (`created`) INDEX `created` (`created`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE parsed_url -- TABLE parsed_url
@ -689,7 +689,7 @@ CREATE TABLE IF NOT EXISTS `parsed_url` (
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`url`,`guessing`,`oembed`), PRIMARY KEY(`url`,`guessing`,`oembed`),
INDEX `created` (`created`) INDEX `created` (`created`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE pconfig -- TABLE pconfig
@ -702,7 +702,7 @@ CREATE TABLE IF NOT EXISTS `pconfig` (
`v` mediumtext, `v` mediumtext,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`) UNIQUE INDEX `uid_cat_k` (`uid`,`cat`,`k`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE photo -- TABLE photo
@ -736,7 +736,7 @@ CREATE TABLE IF NOT EXISTS `photo` (
INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`), INDEX `uid_album_scale_created` (`uid`,`album`(32),`scale`,`created`),
INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`(64),`created`), INDEX `uid_album_resource-id_created` (`uid`,`album`(32),`resource-id`(64),`created`),
INDEX `resource-id` (`resource-id`(64)) INDEX `resource-id` (`resource-id`(64))
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE poll -- TABLE poll
@ -756,7 +756,7 @@ CREATE TABLE IF NOT EXISTS `poll` (
`q9` text, `q9` text,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid` (`uid`) INDEX `uid` (`uid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE poll_result -- TABLE poll_result
@ -768,7 +768,7 @@ CREATE TABLE IF NOT EXISTS `poll_result` (
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `poll_id` (`poll_id`), INDEX `poll_id` (`poll_id`),
INDEX `choice` (`choice`) INDEX `choice` (`choice`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE process -- TABLE process
@ -779,7 +779,7 @@ CREATE TABLE IF NOT EXISTS `process` (
`created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `created` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`pid`), PRIMARY KEY(`pid`),
INDEX `command` (`command`) INDEX `command` (`command`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE profile -- TABLE profile
@ -829,7 +829,7 @@ CREATE TABLE IF NOT EXISTS `profile` (
`net-publish` tinyint(1) NOT NULL DEFAULT 0, `net-publish` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid_is-default` (`uid`,`is-default`) INDEX `uid_is-default` (`uid`,`is-default`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE profile_check -- TABLE profile_check
@ -842,7 +842,7 @@ CREATE TABLE IF NOT EXISTS `profile_check` (
`sec` varchar(255) NOT NULL DEFAULT '', `sec` varchar(255) NOT NULL DEFAULT '',
`expire` int(11) NOT NULL DEFAULT 0, `expire` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE push_subscriber -- TABLE push_subscriber
@ -857,7 +857,7 @@ CREATE TABLE IF NOT EXISTS `push_subscriber` (
`last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `last_update` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`secret` varchar(255) NOT NULL DEFAULT '', `secret` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE queue -- TABLE queue
@ -876,7 +876,7 @@ CREATE TABLE IF NOT EXISTS `queue` (
INDEX `last` (`last`), INDEX `last` (`last`),
INDEX `network` (`network`), INDEX `network` (`network`),
INDEX `batch` (`batch`) INDEX `batch` (`batch`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE register -- TABLE register
@ -890,7 +890,7 @@ CREATE TABLE IF NOT EXISTS `register` (
`language` varchar(16) NOT NULL DEFAULT '', `language` varchar(16) NOT NULL DEFAULT '',
`note` text, `note` text,
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE search -- TABLE search
@ -901,7 +901,7 @@ CREATE TABLE IF NOT EXISTS `search` (
`term` varchar(255) NOT NULL DEFAULT '', `term` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `uid` (`uid`) INDEX `uid` (`uid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE session -- TABLE session
@ -914,7 +914,7 @@ CREATE TABLE IF NOT EXISTS `session` (
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `sid` (`sid`(64)), INDEX `sid` (`sid`(64)),
INDEX `expire` (`expire`) INDEX `expire` (`expire`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE sign -- TABLE sign
@ -927,7 +927,7 @@ CREATE TABLE IF NOT EXISTS `sign` (
`signer` varchar(255) NOT NULL DEFAULT '', `signer` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `iid` (`iid`) INDEX `iid` (`iid`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE spam -- TABLE spam
@ -944,7 +944,7 @@ CREATE TABLE IF NOT EXISTS `spam` (
INDEX `spam` (`spam`), INDEX `spam` (`spam`),
INDEX `ham` (`ham`), INDEX `ham` (`ham`),
INDEX `term` (`term`) INDEX `term` (`term`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE term -- TABLE term
@ -967,7 +967,7 @@ CREATE TABLE IF NOT EXISTS `term` (
INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`), INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)), INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
INDEX `guid` (`guid`(64)) INDEX `guid` (`guid`(64))
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE thread -- TABLE thread
@ -1007,7 +1007,7 @@ CREATE TABLE IF NOT EXISTS `thread` (
INDEX `uid_created` (`uid`,`created`), INDEX `uid_created` (`uid`,`created`),
INDEX `uid_commented` (`uid`,`commented`), INDEX `uid_commented` (`uid`,`commented`),
INDEX `uid_wall_created` (`uid`,`wall`,`created`) INDEX `uid_wall_created` (`uid`,`wall`,`created`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE tokens -- TABLE tokens
@ -1020,7 +1020,7 @@ CREATE TABLE IF NOT EXISTS `tokens` (
`scope` varchar(200) NOT NULL DEFAULT '', `scope` varchar(200) NOT NULL DEFAULT '',
`uid` int(11) NOT NULL DEFAULT 0, `uid` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE user -- TABLE user
@ -1071,7 +1071,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`openidserver` text, `openidserver` text,
PRIMARY KEY(`uid`), PRIMARY KEY(`uid`),
INDEX `nickname` (`nickname`(32)) INDEX `nickname` (`nickname`(32))
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE userd -- TABLE userd
@ -1081,7 +1081,7 @@ CREATE TABLE IF NOT EXISTS `userd` (
`username` varchar(255) NOT NULL, `username` varchar(255) NOT NULL,
PRIMARY KEY(`id`), PRIMARY KEY(`id`),
INDEX `username` (`username`(32)) INDEX `username` (`username`(32))
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;
-- --
-- TABLE workerqueue -- TABLE workerqueue
@ -1094,5 +1094,5 @@ CREATE TABLE IF NOT EXISTS `workerqueue` (
`pid` int(11) NOT NULL DEFAULT 0, `pid` int(11) NOT NULL DEFAULT 0,
`executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00', `executed` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
PRIMARY KEY(`id`) PRIMARY KEY(`id`)
) DEFAULT CHARSET=utf8mb4; ) DEFAULT COLLATE utf8mb4_general_ci;

View file

@ -78,8 +78,18 @@ function update_fail($update_id, $error_message){
function table_structure($table) { function table_structure($table) {
$structures = q("DESCRIBE `%s`", $table); $structures = q("DESCRIBE `%s`", $table);
$full_columns = q("SHOW FULL COLUMNS FROM `%s`", $table);
$indexes = q("SHOW INDEX FROM `%s`", $table); $indexes = q("SHOW INDEX FROM `%s`", $table);
$table_status = q("SHOW TABLE STATUS WHERE `name` = '%s'", $table);
if (dbm::is_result($table_status)) {
$table_status = $table_status[0];
} else {
$table_status = array();
}
$fielddata = array(); $fielddata = array();
$indexdata = array(); $indexdata = array();
@ -104,7 +114,6 @@ function table_structure($table) {
$indexdata[$index["Key_name"]][] = $column; $indexdata[$index["Key_name"]][] = $column;
} }
if (dbm::is_result($structures)) { if (dbm::is_result($structures)) {
foreach ($structures AS $field) { foreach ($structures AS $field) {
$fielddata[$field["Field"]]["type"] = $field["Type"]; $fielddata[$field["Field"]]["type"] = $field["Type"];
@ -125,10 +134,16 @@ function table_structure($table) {
} }
} }
} }
return(array("fields"=>$fielddata, "indexes"=>$indexdata)); if (dbm::is_result($full_columns)) {
foreach ($full_columns AS $column) {
$fielddata[$column["Field"]]["Collation"] = $column["Collation"];
}
}
return array("fields" => $fielddata, "indexes" => $indexdata, "table_status" => $table_status);
} }
function print_structure($database, $charset) { function print_structure($database) {
echo "-- ------------------------------------------\n"; echo "-- ------------------------------------------\n";
echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n"; echo "-- ".FRIENDICA_PLATFORM." ".FRIENDICA_VERSION." (".FRIENDICA_CODENAME,")\n";
echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n"; echo "-- DB_UPDATE_VERSION ".DB_UPDATE_VERSION."\n";
@ -137,7 +152,7 @@ function print_structure($database, $charset) {
echo "--\n"; echo "--\n";
echo "-- TABLE $name\n"; echo "-- TABLE $name\n";
echo "--\n"; echo "--\n";
db_create_table($name, $structure['fields'], $charset, true, false, $structure["indexes"]); db_create_table($name, $structure['fields'], true, false, $structure["indexes"]);
echo "\n"; echo "\n";
} }
@ -148,13 +163,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
if ($action) { if ($action) {
Config::set('system', 'maintenance', 1); Config::set('system', 'maintenance', 1);
Config::set('system', 'maintenance_reason', 'Database update'); Config::set('system', 'maintenance_reason', sprintf(t(': Database update'), dbm::date().' '.date('e')));
}
if (isset($a->config["system"]["db_charset"])) {
$charset = $a->config["system"]["db_charset"];
} else {
$charset = "utf8";
} }
$errors = false; $errors = false;
@ -168,16 +177,18 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
$tables = q("SHOW TABLES"); $tables = q("SHOW TABLES");
} }
if (dbm::is_result($tables)) {
foreach ($tables AS $table) { foreach ($tables AS $table) {
$table = current($table); $table = current($table);
logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG); logger(sprintf('updating structure for table %s ...', $table), LOGGER_DEBUG);
$database[$table] = table_structure($table); $database[$table] = table_structure($table);
} }
}
// Get the definition // Get the definition
if (is_null($definition)) { if (is_null($definition)) {
$definition = db_definition($charset); $definition = db_definition();
} }
// MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements // MySQL >= 5.7.4 doesn't support the IGNORE keyword in ALTER TABLE statements
@ -194,7 +205,7 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
$group_by = ""; $group_by = "";
$sql3 = ""; $sql3 = "";
if (!isset($database[$name])) { if (!isset($database[$name])) {
$r = db_create_table($name, $structure["fields"], $charset, $verbose, $action, $structure['indexes']); $r = db_create_table($name, $structure["fields"], $verbose, $action, $structure['indexes']);
if (!dbm::is_result($r)) { if (!dbm::is_result($r)) {
$errors .= t('Errors encountered creating database tables.').$name.EOL; $errors .= t('Errors encountered creating database tables.').$name.EOL;
} }
@ -252,17 +263,25 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
} }
} else { } else {
// Compare the field definition // Compare the field definition
$current_field_definition = implode(",",$database[$name]["fields"][$fieldname]); $field_definition = $database[$name]["fields"][$fieldname];
$new_field_definition = implode(",",$parameters);
// Define the default collation if not given
if (!isset($parameters['Collation']) AND !is_null($field_definition['Collation'])) {
$parameters['Collation'] = 'utf8mb4_general_ci';
} else {
$parameters['Collation'] = null;
}
$current_field_definition = implode(",", $field_definition);
$new_field_definition = implode(",", $parameters);
if ($current_field_definition != $new_field_definition) { if ($current_field_definition != $new_field_definition) {
$sql2=db_modify_table_field($fieldname, $parameters); $sql2 = db_modify_table_field($fieldname, $parameters);
if ($sql3 == "") { if ($sql3 == "") {
$sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
} else { } else {
$sql3 .= ", ".$sql2; $sql3 .= ", ".$sql2;
} }
} }
} }
} }
} }
@ -288,9 +307,22 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
$group_by = db_group_by($indexname, $fieldnames); $group_by = db_group_by($indexname, $fieldnames);
} }
if ($sql2 != "") { if ($sql2 != "") {
if ($sql3 == "") if ($sql3 == "") {
$sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2; $sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
else } else {
$sql3 .= ", ".$sql2;
}
}
}
}
if (isset($database[$name]["table_status"]["Collation"])) {
if ($database[$name]["table_status"]["Collation"] != 'utf8mb4_general_ci') {
$sql2 = "DEFAULT COLLATE utf8mb4_general_ci";
if ($sql3 == "") {
$sql3 = "ALTER" . $ignore . " TABLE `".$temp_name."` ".$sql2;
} else {
$sql3 .= ", ".$sql2; $sql3 .= ", ".$sql2;
} }
} }
@ -323,6 +355,8 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
} }
if ($action) { if ($action) {
Config::set('system', 'maintenance_reason', sprintf(t('%s: updating %s table.'), dbm::date().' '.date('e'), $name));
// Ensure index conversion to unique removes duplicates // Ensure index conversion to unique removes duplicates
if ($is_unique) { if ($is_unique) {
if ($ignore != "") { if ($ignore != "") {
@ -376,6 +410,10 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
function db_field_command($parameters, $create = true) { function db_field_command($parameters, $create = true) {
$fieldstruct = $parameters["type"]; $fieldstruct = $parameters["type"];
if (!is_null($parameters["Collation"])) {
$fieldstruct .= " COLLATE ".$parameters["Collation"];
}
if ($parameters["not null"]) if ($parameters["not null"])
$fieldstruct .= " NOT NULL"; $fieldstruct .= " NOT NULL";
@ -395,7 +433,7 @@ function db_field_command($parameters, $create = true) {
return($fieldstruct); return($fieldstruct);
} }
function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=null) { function db_create_table($name, $fields, $verbose, $action, $indexes=null) {
global $a, $db; global $a, $db;
$r = true; $r = true;
@ -420,7 +458,7 @@ function db_create_table($name, $fields, $charset, $verbose, $action, $indexes=n
$sql = implode(",\n\t", $sql_rows); $sql = implode(",\n\t", $sql_rows);
$sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT CHARSET=".$charset; $sql = sprintf("CREATE TABLE IF NOT EXISTS `%s` (\n\t", dbesc($name)).$sql."\n) DEFAULT COLLATE utf8mb4_general_ci";
if ($verbose) if ($verbose)
echo $sql.";\n"; echo $sql.";\n";
@ -503,18 +541,7 @@ function db_group_by($indexname, $fieldnames) {
return $sql; return $sql;
} }
function db_index_suffix($charset, $reduce = 0) { function db_definition() {
if ($charset != "utf8mb4") {
return "";
}
// On utf8mb4 indexes can only have a length of 191
$indexlength = 191 - $reduce;
return "(".$indexlength.")";
}
function db_definition($charset) {
$database = array(); $database = array();
@ -1658,9 +1685,7 @@ function dbstructure_run(&$argv, &$argc) {
set_config('system','build',DB_UPDATE_VERSION); set_config('system','build',DB_UPDATE_VERSION);
return; return;
case "dumpsql": case "dumpsql":
// For the dump that is used to create the database.sql we always assume utfmb4 print_structure(db_definition());
$charset = "utf8mb4";
print_structure(db_definition($charset), $charset);
return; return;
} }
} }

View file

@ -1,6 +1,6 @@
<?php <?php
define('UPDATE_VERSION' , 1217); define('UPDATE_VERSION' , 1218);
/** /**
* *