X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=upgrade%2Fnewdirectory-0.0.1%2F02_networking.sql;h=0e4667db827cad3cc267c7a3ec5d3623e4f0a4da;hb=0b14a85c429ad2ff39ee866df4d65de453e6beec;hp=17172c93ecffb6547dd2a435b5e8952426dbc1e4;hpb=5818ad2405cfb20b4cb906711040ab6681f3209b;p=platal.git diff --git a/upgrade/newdirectory-0.0.1/02_networking.sql b/upgrade/newdirectory-0.0.1/02_networking.sql index 17172c9..0e4667d 100644 --- a/upgrade/newdirectory-0.0.1/02_networking.sql +++ b/upgrade/newdirectory-0.0.1/02_networking.sql @@ -1,44 +1,47 @@ -CREATE TABLE IF NOT EXISTS `profile_networking_enum` ( - `network_type` tinyint unsigned NOT NULL, +DROP TABLE IF EXISTS profile_networking_enum; +DROP TABLE IF EXISTS profile_networking; + +CREATE TABLE `profile_networking_enum` ( + `nwid` tinyint unsigned NOT NULL, `name` varchar(30) NOT NULL, `icon` varchar(50) NOT NULL COMMENT 'icon filename', `filter` enum('email','web','number','none') NOT NULL DEFAULT 'none' COMMENT 'filter type for addresses', + `network_type` enum('web','im','social','other') NOT NULL DEFAULT 'other', `link` varchar(255) NOT NULL COMMENT 'string used to forge an URL linking to the the profile page', - PRIMARY KEY (`network_type`) -) CHARSET=utf8 COMMENT='types of networking addresses'; + PRIMARY KEY (`nwid`) +) ENGINE=InnoDB, CHARSET=utf8, COMMENT='types of networking addresses'; + -CREATE TABLE IF NOT EXISTS `profile_networking` ( - `uid` int NOT NULL COMMENT 'user id', - `nwid` tinyint unsigned NOT NULL COMMENT 'number of the address for the user', - `network_type` tinyint unsigned NOT NULL, +CREATE TABLE `profile_networking` ( + `pid` int NOT NULL COMMENT 'profile id', + `id` tinyint unsigned NOT NULL COMMENT 'number of the address for the user', + `nwid` tinyint unsigned NOT NULL COMMENT 'id of network, see profile_networking_enum', `address` varchar(255) NOT NULL, `pub` enum('private','public') NOT NULL DEFAULT 'private', - PRIMARY KEY (`uid`, `nwid`) -) CHARSET=utf8 COMMENT='networking addresses'; + PRIMARY KEY (`pid`, `id`), + INDEX uid (pid) +) ENGINE=InnoDB, CHARSET=utf8, COMMENT='networking addresses'; -- Insert a first address type for old URLs -INSERT INTO `profile_networking_enum` (`network_type`, `name`, `icon`, `filter`) - VALUES (0, 'Page web', 'web.gif', 'web'); +INSERT INTO `profile_networking_enum` (`nwid`, `name`, `icon`, `filter`, `network_type`, `link`) + VALUES (0, 'Page web', 'web.gif', 'web', 'web', '%s'); -INSERT INTO `profile_networking` (`uid`, `nwid`, `network_type`, `address`, `pub`) +INSERT INTO `profile_networking` (`pid`, `id`, `nwid`, `address`, `pub`) SELECT `user_id`, 0, 0, `profile_web`, `profile_web_pub` - FROM `auth_user_quick` + FROM #x4dat#.`auth_user_quick` WHERE `profile_web` <> ""; -- Modify watch_profile to update 'field' from web to networking -ALTER TABLE `watch_profile` - MODIFY `field` enum('nom', 'freetext', 'mobile', 'nationalite', 'nick', - 'web', 'networking', 'appli1', 'appli2', 'addresses', - 'section', 'binets', 'medals', 'cv', 'jobs', 'photo'); +ALTER TABLE watch_profile + MODIFY field ENUM('nom', 'freetext', 'mobile', 'nationality1', 'nationality2', 'nationality3', + 'nick', 'web', 'networking', 'appli1', 'appli2', 'addresses', 'section', + 'binets', 'medals', 'cv', 'jobs', 'photo'); UPDATE `watch_profile` SET `field` = 'networking' WHERE `field` = 'web'; -ALTER TABLE `watch_profile` - MODIFY `field` enum('nom', 'freetext', 'mobile', 'nationalite', 'nick', - 'networking', 'appli1', 'appli2', 'addresses', - 'section', 'binets', 'medals', 'cv', 'jobs', 'photo'); - --- Drop old web URL columns -ALTER TABLE `auth_user_quick` DROP COLUMN `profile_web`; -ALTER TABLE `auth_user_quick` DROP COLUMN `profile_web_pub`; +ALTER TABLE watch_profile + MODIFY field ENUM('nom', 'freetext', 'mobile', 'nationality1', 'nationality2', 'nationality3', + 'nick', 'networking', 'appli1', 'appli2', 'addresses', 'section', + 'binets', 'medals', 'cv', 'jobs', 'photo'); +# vim:set syntax=mysql: