Skip to content

Commit

Permalink
Use UTF-8 for the database
Browse files Browse the repository at this point in the history
  • Loading branch information
gboudreau committed Sep 22, 2013
1 parent d190605 commit 242b12a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
17 changes: 9 additions & 8 deletions includes/sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function db_migrate($attempt_repair = TRUE) {
if ($row->Field == 'value') {
if ($row->Type == "tinytext") {
// migrate
db_query("ALTER TABLE settings CHANGE value value TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL");
db_query("ALTER TABLE settings CHANGE value value TEXT CHARACTER SET utf8 NOT NULL");
}
break;
}
Expand Down Expand Up @@ -201,7 +201,8 @@ function db_migrate($attempt_repair = TRUE) {
$result = db_query($query) or die("Can't show index with query: $query - Error: " . db_error());
if (db_fetch_object($result) !== FALSE) {
// migrate
db_query("ALTER TABLE tasks DROP INDEX find_next_task ADD INDEX find_next_task (complete, id)");
db_query("ALTER TABLE tasks DROP INDEX find_next_task");
db_query("ALTER TABLE tasks ADD INDEX find_next_task (complete, id)");
}
}

Expand All @@ -218,7 +219,7 @@ function db_migrate($attempt_repair = TRUE) {
$result = db_query($query) or die("Can't show index with query: $query - Error: " . db_error());
if (db_fetch_object($result) === FALSE) {
// migrate
db_query("ALTER TABLE tasks ADD INDEX md5_checker (action, share(64), full_path(255), complete)");
db_query("ALTER TABLE tasks ADD INDEX md5_checker (action, share(64), full_path(265), complete)");
}

$query = "DESCRIBE tasks";
Expand All @@ -227,7 +228,7 @@ function db_migrate($attempt_repair = TRUE) {
if ($row->Field == 'additional_info') {
if ($row->Type == "tinytext") {
// migrate
db_query("ALTER TABLE tasks CHANGE additional_info additional_info TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL");
db_query("ALTER TABLE tasks CHANGE additional_info additional_info TEXT CHARACTER SET utf8 NULL");
}
break;
}
Expand All @@ -242,8 +243,8 @@ function db_migrate($attempt_repair = TRUE) {
if ($row->Field == 'full_path') {
if ($row->Type == "tinytext") {
// migrate
db_query("ALTER TABLE tasks CHANGE full_path full_path TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL");
db_query("ALTER TABLE tasks_completed CHANGE full_path full_path TEXT CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL");
db_query("ALTER TABLE tasks CHANGE full_path full_path TEXT CHARACTER SET utf8 NULL");
db_query("ALTER TABLE tasks_completed CHANGE full_path full_path TEXT CHARACTER SET utf8 NULL");
}
break;
}
Expand All @@ -252,7 +253,7 @@ function db_migrate($attempt_repair = TRUE) {

// Migration #8 (new du_stats table)
if (@$db_use_mysql) {
$query = "CREATE TABLE IF NOT EXISTS `du_stats` (`share` TINYTEXT NOT NULL, `full_path` TEXT NOT NULL, `depth` TINYINT(3) UNSIGNED NOT NULL, `size` BIGINT(20) NOT NULL) ENGINE = MYISAM";
$query = "CREATE TABLE IF NOT EXISTS `du_stats` (`share` TINYTEXT NOT NULL, `full_path` TEXT NOT NULL, `depth` TINYINT(3) UNSIGNED NOT NULL, `size` BIGINT(20) UNSIGNED NOT NULL, UNIQUE KEY `uniqness` (`share`(64),`full_path`(269))) ENGINE = MYISAM DEFAULT CHARSET=utf8";
} else {
$query = "CREATE TABLE IF NOT EXISTS du_stats (share TINYTEXT NOT NULL, full_path TEXT NOT NULL, depth INTEGER, size INTEGER)";
}
Expand All @@ -262,7 +263,7 @@ function db_migrate($attempt_repair = TRUE) {
$result = db_query($query) or die("Can't show index with query: $query - Error: " . db_error());
if (db_fetch_object($result) === FALSE) {
// migrate
db_query("ALTER TABLE `du_stats` ADD UNIQUE `uniqness` (`share` (64), `full_path` (936))");
db_query("ALTER TABLE `du_stats` ADD UNIQUE `uniqness` (`share` (64), `full_path` (269))");
}
}
}
Expand Down
35 changes: 19 additions & 16 deletions schema-mysql.sql
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
CREATE TABLE `settings` (
`name` TINYTEXT NOT NULL,
`name` TINYTEXT CHARACTER SET ascii NOT NULL,
`value` TEXT NOT NULL,
PRIMARY KEY ( `name`(255) )
) ENGINE = MYISAM;
) ENGINE = MYISAM DEFAULT CHARSET=utf8;

INSERT INTO `settings` (`name`, `value`) VALUES ('last_read_log_smbd_line', '0');
INSERT INTO `settings` (`name`, `value`) VALUES ('last_OOS_notification', '0');

CREATE TABLE `tasks` (
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
`action` VARCHAR( 10 ) NOT NULL,
`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
`action` VARCHAR( 10 ) CHARACTER SET ascii NOT NULL,
`share` TINYTEXT NOT NULL,
`full_path` TINYTEXT NULL,
`additional_info` TINYTEXT NULL,
`complete` ENUM( 'yes', 'no', 'frozen', 'thawed', 'idle') NOT NULL,
`event_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE = MYISAM;

ALTER TABLE `tasks` ADD INDEX `find_next_task` ( `complete` , `share` (64) , `id` );
`full_path` TEXT NULL,
`additional_info` TEXT NULL,
`complete` ENUM( 'yes', 'no', 'frozen', 'thawed', 'idle') CHARACTER SET ascii NOT NULL,
`event_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `md5_worker` (`action`,`complete`,`additional_info`(100),`id`),
KEY `find_next_task` (`complete`,`id`),
KEY `md5_checker` (`action`,`share`(64),`full_path`(265),`complete`)
) ENGINE = MYISAM DEFAULT CHARSET=utf8;

CREATE TABLE `tasks_completed` (
`id` BIGINT UNSIGNED NOT NULL,
`action` VARCHAR( 10 ) NOT NULL,
`action` VARCHAR( 10 ) CHARACTER SET ascii NOT NULL,
`share` TINYTEXT NOT NULL,
`full_path` TINYTEXT NULL,
`additional_info` TINYTEXT NULL,
`complete` ENUM( 'yes', 'no' ) NOT NULL,
`complete` ENUM( 'yes', 'no', 'frozen', 'thawed', 'idle' ) CHARACTER SET ascii NOT NULL,
`event_date` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE = MYISAM;
) ENGINE = MYISAM DEFAULT CHARSET=utf8;

CREATE TABLE `du_stats` (
`share` TINYTEXT NOT NULL,
`full_path` TEXT NOT NULL,
`depth` TINYINT(3) UNSIGNED NOT NULL,
`size` BIGINT(20) NOT NULL
) ENGINE = MYISAM;
`size` BIGINT(20) UNSIGNED NOT NULL,
UNIQUE KEY `uniqness` (`share`(64),`full_path`(269))
) ENGINE = MYISAM DEFAULT CHARSET=utf8;

0 comments on commit 242b12a

Please sign in to comment.