root/sql-files/upgrade_svn11548.sql @ 1

Revision 1, 2.1 kB (checked in by jinshiro, 17 years ago)
RevLine 
[1]1-- this will covert the old `mail` table to new format, convert columns and fill in default values --
2
3-- change structure --
4ALTER TABLE `mail` CHANGE `message_id` `id` bigint(20) unsigned NOT NULL auto_increment;
5ALTER TABLE `mail` CHANGE `from_char_name` `send_name` varchar(30) NOT NULL default '' AFTER `id`;
6ALTER TABLE `mail` CHANGE `from_account_id` `send_id` int(11) unsigned NOT NULL default 0 AFTER `send_name`;
7ALTER TABLE `mail` CHANGE `to_char_name` `dest_name` varchar(30) NOT NULL default '' AFTER `send_id`;
8ALTER TABLE `mail` CHANGE `to_account_id` `dest_id` int(11) unsigned NOT NULL default 0 AFTER `dest_name`;
9ALTER TABLE `mail` ADD `title` varchar(45) NOT NULL default '' AFTER `dest_id`;
10ALTER TABLE `mail` CHANGE `message` `message` varchar(255) NOT NULL default '' AFTER `title`;
11ALTER TABLE `mail` ADD `time` int(11) unsigned NOT NULL default 0 AFTER `message`;
12ALTER TABLE `mail` CHANGE `read_flag` `read_flag` tinyint(1) NOT NULL default 0 AFTER `time`;
13ALTER TABLE `mail` ADD `zeny` int(11) unsigned NOT NULL default 0 AFTER `read_flag`;
14ALTER TABLE `mail` ADD `nameid` int(11) unsigned NOT NULL default 0 AFTER `zeny`;
15ALTER TABLE `mail` ADD `amount` int(11) unsigned NOT NULL default 0 AFTER `nameid`;
16ALTER TABLE `mail` ADD `refine` tinyint(3) unsigned NOT NULL default 0 AFTER `amount`;
17ALTER TABLE `mail` ADD `attribute` tinyint(4) unsigned NOT NULL default 0 AFTER `refine`;
18ALTER TABLE `mail` ADD `identify` smallint(6) NOT NULL default 0 AFTER `attribute`;
19ALTER TABLE `mail` ADD `card0` smallint(11) NOT NULL default 0 AFTER `identify`;
20ALTER TABLE `mail` ADD `card1` smallint(11) NOT NULL default 0 AFTER `card0`;
21ALTER TABLE `mail` ADD `card2` smallint(11) NOT NULL default 0 AFTER `card1`;
22ALTER TABLE `mail` ADD `card3` smallint(11) NOT NULL default 0 AFTER `card2`;
23ALTER TABLE `mail` DROP `priority`;
24ALTER TABLE `mail` DROP `check_flag`;
25
26-- correct values in some columns --
27UPDATE `mail` SET `time` = UNIX_TIMESTAMP(NOW());
28UPDATE `mail` SET `send_id` = (SELECT `char_id` FROM `char` WHERE `name` = `send_name`);
29UPDATE `mail` SET `dest_id` = (SELECT `char_id` FROM `char` WHERE `name` = `dest_name`);
Note: See TracBrowser for help on using the browser.