Adds the possibility to forge an url linking to a profile page from networking addresses
[platal.git] / upgrade / fusionax-0.0.1 / 02_networking.sql
1 CREATE TABLE IF NOT EXISTS `profile_networking_enum` (
2 `network_type` tinyint unsigned NOT NULL,
3 `name` varchar(30) NOT NULL,
4 `icon` varchar(50) NOT NULL COMMENT 'icon filename',
5 `filter` enum('email','web','number','none') NOT NULL DEFAULT 'none' COMMENT 'filter type for addresses',
6 `link` varchar(255) NOT NULL COMMENT 'string used to forge an URL linking to the the profile page',
7 PRIMARY KEY (`network_type`)
8 ) CHARSET=utf8 COMMENT='types of networking addresses';
9
10 CREATE TABLE IF NOT EXISTS `profile_networking` (
11 `uid` int NOT NULL COMMENT 'user id',
12 `nwid` tinyint unsigned NOT NULL COMMENT 'number of the address for the user',
13 `network_type` tinyint unsigned NOT NULL,
14 `address` varchar(255) NOT NULL,
15 `pub` enum('private','public') NOT NULL DEFAULT 'private',
16 PRIMARY KEY (`uid`, `nwid`)
17 ) CHARSET=utf8 COMMENT='networking addresses';
18
19 -- Insert a first address type for old URLs
20 INSERT INTO `profile_networking_enum` (`network_type`, `name`, `icon`, `filter`)
21 VALUES (0, 'Page web', 'web.gif', 'web');
22
23 INSERT INTO `profile_networking` (`uid`, `nwid`, `network_type`, `address`, `pub`)
24 SELECT `user_id`, 0, 0, `profile_web`, `profile_web_pub`
25 FROM `auth_user_quick`
26 WHERE `profile_web` <> "";
27
28 -- Modify watch_profile to update 'field' from web to networking
29 ALTER TABLE `watch_profile`
30 MODIFY `field` enum('nom', 'freetext', 'mobile', 'nationalite', 'nick',
31 'web', 'networking', 'appli1', 'appli2', 'addresses',
32 'section', 'binets', 'medals', 'cv', 'jobs', 'photo');
33
34 UPDATE `watch_profile` SET `field` = 'networking' WHERE `field` = 'web';
35
36 ALTER TABLE `watch_profile`
37 MODIFY `field` enum('nom', 'freetext', 'mobile', 'nationalite', 'nick',
38 'networking', 'appli1', 'appli2', 'addresses',
39 'section', 'binets', 'medals', 'cv', 'jobs', 'photo');
40
41 -- Drop old web URL columns
42 ALTER TABLE `auth_user_quick` DROP COLUMN `profile_web`;
43 ALTER TABLE `auth_user_quick` DROP COLUMN `profile_web_pub`;
44