-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade.sql
67 lines (61 loc) · 2.68 KB
/
upgrade.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
alter table posts add locked char(1) default 'N';
alter table users add moderator char(1) default 'N';
alter table posts add edited_at int(18) unsigned after modified_at;
alter table posts_replies add edited_at int(18) unsigned;
alter table users add karma int;
alter table posts_replies add votes_up int unsigned;
alter table posts_replies add votes_down int unsigned;
alter table posts add votes_up int unsigned after number_replies;
alter table posts add votes_down int unsigned after votes_up;
alter table users add votes int unsigned;
alter table users add votes_points int;
alter table posts add deleted int(3) default 0;
alter table posts add index `deleted`(deleted);
update posts set votes_up = (number_views / 50) - 1 where votes_up is null;
update posts set votes_up = null where votes_up = 0;
update users set votes_points = 0 where votes_points is null;
CREATE TABLE `posts_history` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`posts_id` int(10) unsigned NOT NULL,
`users_id` int(10) unsigned NOT NULL,
`created_at` int(18) unsigned NOT NULL,
`content` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
KEY `posts_id` (`posts_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `posts_replies_history` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`posts_replies_id` int(10) unsigned NOT NULL,
`users_id` int(10) unsigned NOT NULL,
`created_at` int(18) unsigned NOT NULL,
`content` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
KEY `posts_replies_id` (`posts_replies_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `posts_votes` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`posts_id` int(10) unsigned NOT NULL,
`users_id` int(10) unsigned NOT NULL,
`created_at` int(18) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE `posts_replies_votes` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`posts_replies_id` int(10) unsigned NOT NULL,
`users_id` int(10) unsigned NOT NULL,
`created_at` int(18) unsigned NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
alter table posts_replies add accepted char(1) default 'N';
alter table posts add accepted_answer char(1) default 'N';
CREATE TABLE `posts_bounties` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`posts_id` int(10) unsigned NOT NULL,
`users_id` int(10) unsigned NOT NULL,
`posts_replies_id` int(10) unsigned NOT NULL,
`points` int(10) unsigned NOT NULL,
`created_at` int(18) NOT NULL,
PRIMARY KEY (`id`),
KEY `users_id` (`users_id`,`posts_replies_id`),
KEY `posts_id` (`posts_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;