Minor fix: convert tables and data from ISO to UTF-8

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@249 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
mensonge 2009-02-05 15:22:03 +00:00
parent 6829863847
commit b10bc4065e
2 changed files with 104 additions and 17 deletions

View file

@ -1,4 +1,4 @@
-- Semantice Scuttle - Tables creation SQL script -- Semantic Scuttle - Tables creation SQL script
-- ! Dont forget to change table names according to $tableprefix defined in config.inc.php ! -- ! Dont forget to change table names according to $tableprefix defined in config.inc.php !
-- --
@ -13,15 +13,15 @@ CREATE TABLE `sc_bookmarks` (
`bDatetime` datetime NOT NULL default '0000-00-00 00:00:00', `bDatetime` datetime NOT NULL default '0000-00-00 00:00:00',
`bModified` datetime NOT NULL default '0000-00-00 00:00:00', `bModified` datetime NOT NULL default '0000-00-00 00:00:00',
`bTitle` varchar(255) NOT NULL default '', `bTitle` varchar(255) NOT NULL default '',
`bAddress` text NOT NULL, `bAddress` varchar(1500) NOT NULL,
`bDescription` varchar(1500) default NULL, `bDescription` text default NULL,
`bPrivateNote` varchar(1500) default NULL, `bPrivateNote` text default NULL,
`bHash` varchar(32) NOT NULL default '', `bHash` varchar(32) NOT NULL default '',
PRIMARY KEY (`bId`), PRIMARY KEY (`bId`),
KEY `sc_bookmarks_usd` (`uId`,`bStatus`,`bDatetime`), KEY `sc_bookmarks_usd` (`uId`,`bStatus`,`bDatetime`),
KEY `sc_bookmarks_hui` (`bHash`,`uId`,`bId`), KEY `sc_bookmarks_hui` (`bHash`,`uId`,`bId`),
KEY `sc_bookmarks_du` (`bDatetime`,`uId`) KEY `sc_bookmarks_du` (`bDatetime`,`uId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -33,10 +33,10 @@ CREATE TABLE `sc_tags` (
`tId` int(11) NOT NULL auto_increment, `tId` int(11) NOT NULL auto_increment,
`tag` varchar(100) NOT NULL default '', `tag` varchar(100) NOT NULL default '',
`uId` int(11) NOT NULL default '0', `uId` int(11) NOT NULL default '0',
`tDescription` varchar(1500) default NULL, `tDescription` text default NULL,
PRIMARY KEY (`tId`), PRIMARY KEY (`tId`),
UNIQUE KEY `sc_tags_tag_uId` (`tag`, `uId`) UNIQUE KEY `sc_tags_tag_uId` (`tag`, `uId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -51,7 +51,7 @@ CREATE TABLE `sc_bookmarks2tags` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `sc_bookmarks2tags_tag_bId` (`tag`,`bId`), UNIQUE KEY `sc_bookmarks2tags_tag_bId` (`tag`,`bId`),
KEY `sc_bookmarks2tags_bId` (`bId`) KEY `sc_bookmarks2tags_bId` (`bId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -70,7 +70,7 @@ CREATE TABLE `sc_users` (
`homepage` varchar(255) default NULL, `homepage` varchar(255) default NULL,
`uContent` text, `uContent` text,
PRIMARY KEY (`uId`) PRIMARY KEY (`uId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -84,7 +84,7 @@ CREATE TABLE `sc_watched` (
`watched` int(11) NOT NULL default '0', `watched` int(11) NOT NULL default '0',
PRIMARY KEY (`wId`), PRIMARY KEY (`wId`),
KEY `sc_watched_uId` (`uId`) KEY `sc_watched_uId` (`uId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -100,7 +100,7 @@ CREATE TABLE `sc_tags2tags` (
`uId` int(11) NOT NULL default '0', `uId` int(11) NOT NULL default '0',
PRIMARY KEY (`ttId`), PRIMARY KEY (`ttId`),
UNIQUE KEY `sc_tags2tags_tag1_tag2_uId` (`tag1`,`tag2`,`relationType`,`uId`) UNIQUE KEY `sc_tags2tags_tag1_tag2_uId` (`tag1`,`tag2`,`relationType`,`uId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -118,7 +118,7 @@ CREATE TABLE `sc_tagsstats` (
`nbupdate` int(11) NOT NULL default '0', `nbupdate` int(11) NOT NULL default '0',
PRIMARY KEY (`tstId`), PRIMARY KEY (`tstId`),
UNIQUE KEY `sc_tagsstats_tag1_type_uId` (`tag1`,`relationType`,`uId`) UNIQUE KEY `sc_tagsstats_tag1_type_uId` (`tag1`,`relationType`,`uId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -134,7 +134,7 @@ CREATE TABLE `sc_tagscache` (
`uId` int(11) NOT NULL default '0', `uId` int(11) NOT NULL default '0',
PRIMARY KEY (`tcId`), PRIMARY KEY (`tcId`),
UNIQUE KEY `sc_tagscache_tag1_tag2_type_uId` (`tag1`,`tag2`,`relationType`,`uId`) UNIQUE KEY `sc_tagscache_tag1_tag2_type_uId` (`tag1`,`tag2`,`relationType`,`uId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -148,12 +148,12 @@ CREATE TABLE `sc_commondescription` (
`tag` varchar(100) NOT NULL default '', `tag` varchar(100) NOT NULL default '',
`bHash` varchar(32) NOT NULL default '', `bHash` varchar(32) NOT NULL default '',
`cdTitle` varchar(255) NOT NULL default '', `cdTitle` varchar(255) NOT NULL default '',
`cdDescription` varchar(1500) default NULL, `cdDescription` text default NULL,
`cdDatetime` datetime NOT NULL default '0000-00-00 00:00:00', `cdDatetime` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`cdId`), PRIMARY KEY (`cdId`),
UNIQUE KEY `sc_commondescription_tag_datetime` (`tag`,`cdDatetime`), UNIQUE KEY `sc_commondescription_tag_datetime` (`tag`,`cdDatetime`),
UNIQUE KEY `sc_commondescription_bookmark_datetime` (`bHash`,`cdDatetime`) UNIQUE KEY `sc_commondescription_bookmark_datetime` (`bHash`,`cdDatetime`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;
-- -------------------------------------------------------- -- --------------------------------------------------------
@ -169,4 +169,4 @@ CREATE TABLE `sc_searchhistory` (
`shNbResults` int(6) NOT NULL default '0', `shNbResults` int(6) NOT NULL default '0',
`uId` int(11) NOT NULL default '0', `uId` int(11) NOT NULL default '0',
PRIMARY KEY (`shId`) PRIMARY KEY (`shId`)
); ) CHARACTER SET utf8 COLLATE utf8_general_ci ;

View file

@ -1,10 +1,97 @@
==== UPGRADE instructions ==== ==== UPGRADE instructions ====
=== From version 0.91 to 0.92 === === From version 0.91 to 0.92 ===
Message: this version modifies the database to UTF-8 charset. The idea is to convert the content (through BLOB type) and then to change the tables' charsets.
- Backup you database - Backup you database
- Make a copy from your SemanticScuttle Web directory - Make a copy from your SemanticScuttle Web directory
- Upgrade your database by following instructions ONE after ONE (order is important) : - Upgrade your database by following instructions ONE after ONE (order is important) :
* ALTER TABLE `sc_bookmarks` ADD `bPrivateNote` VARCHAR( 1500 ) NULL AFTER `bDescription` ;
/* modify and add fields */
ALTER TABLE `sc_bookmarks` MODIFY `bAddress` varchar(1500) NOT NULL;
ALTER TABLE `sc_bookmarks` MODIFY `bDescription` TEXT default NULL;
ALTER TABLE `sc_bookmarks` ADD `bPrivateNote` TEXT NULL AFTER `bDescription` ;
ALTER TABLE `sc_tags` MODIFY `tDescription` TEXT default NULL;
ALTER TABLE `sc_commondescription` MODIFY `cdDescription` TEXT default NULL;
/* convert to UTF-8 if your table is ISO-something (through BLOB: tips provided by MYSQL documentation)*/
/* first need to remove index keys because of BLOB constraints*/
ALTER TABLE `sc_tags` DROP INDEX `sc_tags_tag_uId`;
ALTER TABLE `sc_bookmarks2tags` DROP INDEX `sc_bookmarks2tags_tag_bId`;
ALTER TABLE `sc_bookmarks2tags` DROP INDEX `sc_bookmarks2tags_bId`;
ALTER TABLE `sc_tags2tags` DROP INDEX `sc_tags2tags_tag1_tag2_uId`;
ALTER TABLE `sc_commondescription` DROP INDEX `sc_commondescription_tag_datetime`;
ALTER TABLE `sc_tagscache` DROP INDEX `sc_tagscache_tag1_tag2_type_uId`;
ALTER TABLE `sc_tagsstats` DROP INDEX `sc_tagsstats_tag1_type_uId`;
/* secondly convert through BLOB type */
ALTER TABLE `sc_bookmarks` CHANGE `bTitle` `bTitle` BLOB;
ALTER TABLE `sc_bookmarks` CHANGE `bTitle` `bTitle` varchar(255) CHARACTER SET utf8;
ALTER TABLE `sc_bookmarks` CHANGE `bAddress` `bAddress` BLOB;
ALTER TABLE `sc_bookmarks` CHANGE `bAddress` `bAddress` varchar(1500) CHARACTER SET utf8;
ALTER TABLE `sc_bookmarks` CHANGE `bDescription` `bDescription` BLOB;
ALTER TABLE `sc_bookmarks` CHANGE `bDescription` `bDescription` text CHARACTER SET utf8;
ALTER TABLE `sc_bookmarks` CHANGE `bPrivateNote` `bPrivateNote` BLOB;
ALTER TABLE `sc_bookmarks` CHANGE `bPrivateNote` `bPrivateNote` text CHARACTER SET utf8;
ALTER TABLE `sc_tags` CHANGE `tag` `tag` BLOB;
ALTER TABLE `sc_tags` CHANGE `tag` `tag` varchar(100) CHARACTER SET utf8;
ALTER TABLE `sc_tags` CHANGE `tDescription` `tDescription` BLOB;
ALTER TABLE `sc_tags` CHANGE `tDescription` `tDescription` text CHARACTER SET utf8;
ALTER TABLE `sc_bookmarks2tags` CHANGE `tag` `tag` BLOB;
ALTER TABLE `sc_bookmarks2tags` CHANGE `tag` `tag` varchar(100) CHARACTER SET utf8;
ALTER TABLE `sc_users` CHANGE `name` `name` BLOB;
ALTER TABLE `sc_users` CHANGE `name` `name` varchar(50) CHARACTER SET utf8;
ALTER TABLE `sc_users` CHANGE `uContent` `uContent` BLOB;
ALTER TABLE `sc_users` CHANGE `uContent` `uContent` text CHARACTER SET utf8;
ALTER TABLE `sc_tags2tags` CHANGE `tag1` `tag1` BLOB;
ALTER TABLE `sc_tags2tags` CHANGE `tag1` `tag1` varchar(100) CHARACTER SET utf8;
ALTER TABLE `sc_tags2tags` CHANGE `tag2` `tag2` BLOB;
ALTER TABLE `sc_tags2tags` CHANGE `tag2` `tag2` varchar(100) CHARACTER SET utf8;
ALTER TABLE `sc_tagsstats` CHANGE `tag1` `tag1` BLOB;
ALTER TABLE `sc_tagsstats` CHANGE `tag1` `tag1` varchar(100) CHARACTER SET utf8;
ALTER TABLE `sc_tagscache` CHANGE `tag1` `tag1` BLOB;
ALTER TABLE `sc_tagscache` CHANGE `tag1` `tag1` varchar(100) CHARACTER SET utf8;
ALTER TABLE `sc_tagscache` CHANGE `tag2` `tag2` BLOB;
ALTER TABLE `sc_tagscache` CHANGE `tag2` `tag2` varchar(100) CHARACTER SET utf8;
ALTER TABLE `sc_commondescription` CHANGE `tag` `tag` BLOB;
ALTER TABLE `sc_commondescription` CHANGE `tag` `tag` varchar(100) CHARACTER SET utf8;
ALTER TABLE `sc_commondescription` CHANGE `cdTitle` `cdTitle` BLOB;
ALTER TABLE `sc_commondescription` CHANGE `cdTitle` `cdTitle` varchar(255) CHARACTER SET utf8;
ALTER TABLE `sc_commondescription` CHANGE `cdDescription` `cdDescription` BLOB;
ALTER TABLE `sc_commondescription` CHANGE `cdDescription` `cdDescription` text CHARACTER SET utf8;
ALTER TABLE `sc_searchhistory` CHANGE `shTerms` `shTerms` BLOB;
ALTER TABLE `sc_searchhistory` CHANGE `shTerms` `shTerms` varchar(255) CHARACTER SET utf8;
ALTER TABLE `sc_searchhistory` CHANGE `shRange` `shRange` BLOB;
ALTER TABLE `sc_searchhistory` CHANGE `shRange` `shRange` varchar(32) CHARACTER SET utf8;
/* Thirdly re-add index keys */
ALTER TABLE `sc_tags` ADD UNIQUE KEY `sc_tags_tag_uId` (`tag`, `uId`);
ALTER TABLE `sc_bookmarks2tags` ADD UNIQUE KEY `sc_bookmarks2tags_tag_bId` (`tag`,`bId`);
ALTER TABLE `sc_bookmarks2tags` ADD KEY `sc_bookmarks2tags_bId` (`bId`);
ALTER TABLE `sc_tags2tags` ADD UNIQUE KEY `sc_tags2tags_tag1_tag2_uId` (`tag1`,`tag2`,`relationType`,`uId`);
ALTER TABLE `sc_commondescription` ADD UNIQUE KEY `sc_commondescription_tag_datetime` (`tag`,`cdDatetime`);
ALTER TABLE `sc_tagscache` ADD UNIQUE KEY `sc_tagscache_tag1_tag2_type_uId` (`tag1`,`tag2`,`relationType`,`uId`);
ALTER TABLE `sc_tagsstats` ADD UNIQUE KEY `sc_tagsstats_tag1_type_uId` (`tag1`,`relationType`,`uId`);
/* Change tables to utf-8 charset */
ALTER TABLE `sc_bookmarks` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_tags` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_bookmarks2tags` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_users` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_watched` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_tags2tags` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_tagsstats` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_tagscache` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_commondescription` CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `sc_searchhistory` CHARACTER SET utf8 COLLATE utf8_general_ci;
- Upgrade your current configuration file (config.inc.php) with respect to config.inc.php.example - Upgrade your current configuration file (config.inc.php) with respect to config.inc.php.example
* Add variable : $descriptionAnchors = array("author", "isbn", "address"=>"[address][street][/street][city][/city][/address]"); #add a possible anchor (structured content) for bookmarks' description field * Add variable : $descriptionAnchors = array("author", "isbn", "address"=>"[address][street][/street][city][/city][/address]"); #add a possible anchor (structured content) for bookmarks' description field