forked from EngineHub/WorldGuard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
region_storage_update_20110325.sql
106 lines (82 loc) · 4.74 KB
/
region_storage_update_20110325.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
ALTER TABLE `region_cuboid` DROP FOREIGN KEY `fk_region_cuboid_region` ;
ALTER TABLE `region_flag` DROP FOREIGN KEY `fk_flags_region1` ;
ALTER TABLE `region_groups` DROP FOREIGN KEY `fk_region_groups_region` ;
ALTER TABLE `region_players` DROP FOREIGN KEY `fk_region_players_user` , DROP FOREIGN KEY `fk_region_players_region` ;
ALTER TABLE `region_poly2d` DROP FOREIGN KEY `fk_region_poly2d_region` ;
ALTER TABLE `region_poly2d_point` DROP FOREIGN KEY `fk_region_poly2d_point_region_poly2d` ;
ALTER TABLE `group` COLLATE = utf8_bin ;
ALTER TABLE `region_cuboid` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , CHANGE COLUMN `min_x` `min_x` BIGINT(20) NOT NULL AFTER `world_id` , CHANGE COLUMN `min_y` `min_y` BIGINT(20) NOT NULL AFTER `min_x` , CHANGE COLUMN `max_x` `max_x` BIGINT(20) NOT NULL AFTER `min_z` , CHANGE COLUMN `max_y` `max_y` BIGINT(20) NOT NULL AFTER `max_x` ,
ADD CONSTRAINT `fk_region_cuboid_region`
FOREIGN KEY (`region_id` , `world_id` )
REFERENCES `region` (`id` , `world_id` )
ON DELETE CASCADE
ON UPDATE CASCADE
, DROP PRIMARY KEY
, ADD PRIMARY KEY (`region_id`, `world_id`) ;
ALTER TABLE `region_flag` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , CHANGE COLUMN `flag` `flag` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_bin' NOT NULL ,
ADD CONSTRAINT `fk_flags_region`
FOREIGN KEY (`region_id` , `world_id` )
REFERENCES `region` (`id` , `world_id` )
ON DELETE CASCADE
ON UPDATE CASCADE
, DROP INDEX `fk_flags_region`
, ADD INDEX `fk_flags_region` (`region_id` ASC, `world_id` ASC) ;
ALTER TABLE `region_groups` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , DROP FOREIGN KEY `fk_region_groups_group` ;
ALTER TABLE `region_groups`
ADD CONSTRAINT `fk_region_groups_group`
FOREIGN KEY (`group_id` )
REFERENCES `group` (`id` )
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `fk_region_groups_region`
FOREIGN KEY (`region_id` , `world_id` )
REFERENCES `region` (`id` , `world_id` )
ON DELETE CASCADE
ON UPDATE CASCADE
, DROP PRIMARY KEY
, ADD PRIMARY KEY (`region_id`, `world_id`, `group_id`) ;
ALTER TABLE `region_players` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` ,
ADD CONSTRAINT `fk_region_users_region`
FOREIGN KEY (`region_id` , `world_id` )
REFERENCES `region` (`id` , `world_id` )
ON DELETE CASCADE
ON UPDATE CASCADE,
ADD CONSTRAINT `fk_region_users_user`
FOREIGN KEY (`user_id` )
REFERENCES `user` (`id` )
ON DELETE CASCADE
ON UPDATE CASCADE
, DROP PRIMARY KEY
, ADD PRIMARY KEY (`region_id`, `world_id`, `user_id`)
, ADD INDEX `fk_region_users_user` (`user_id` ASC)
, DROP INDEX `fk_region_players_user` ;
ALTER TABLE `region_poly2d` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , CHANGE COLUMN `min_y` `min_y` INT(11) NOT NULL AFTER `world_id` ,
ADD CONSTRAINT `fk_region_poly2d_region`
FOREIGN KEY (`region_id` , `world_id` )
REFERENCES `region` (`id` , `world_id` )
ON DELETE CASCADE
ON UPDATE CASCADE
, DROP PRIMARY KEY
, ADD PRIMARY KEY (`region_id`, `world_id`) ;
ALTER TABLE `region_poly2d_point` COLLATE = utf8_bin , ADD COLUMN `world_id` INT(10) UNSIGNED NOT NULL AFTER `region_id` , CHANGE COLUMN `x` `x` BIGINT(20) NOT NULL AFTER `world_id` ,
ADD CONSTRAINT `fk_region_poly2d_point_region_poly2d`
FOREIGN KEY (`region_id` , `world_id` )
REFERENCES `region_poly2d` (`region_id` , `world_id` )
ON DELETE CASCADE
ON UPDATE CASCADE
, DROP INDEX `fk_region_poly2d_point_region_poly2d`
, ADD INDEX `fk_region_poly2d_point_region_poly2d` (`region_id` ASC, `world_id` ASC) ;
ALTER TABLE `user` COLLATE = utf8_bin ;
ALTER TABLE `world` COLLATE = utf8_bin ;
UPDATE `region_cuboid` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
UPDATE `region_flag` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
UPDATE `region_groups` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
UPDATE `region_players` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
UPDATE `region_poly2d` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
UPDATE `region_poly2d_point` AS c SET c.`world_id` = (SELECT p.`world_id` FROM `region` AS p WHERE p.`id` = c.`region_id`);
SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;