_migration.sql
2.11 KB
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
/*
author: feng.chen@yoho.cn
date: 2017-06-27 11:25:29
comment: 初始化
*/
#注意:GO;分割执行块
CREATE TABLE IF NOT EXISTS user (
`id` int(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`user_phone` varchar(20) NOT NULL DEFAULT '',
`user_name` varchar(100) NOT NULL DEFAULT '',
`user_avatar` varchar(200) NOT NULL DEFAULT '',
`createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
GO;
#活动主表
CREATE TABLE IF NOT EXISTS activity (
`id` int(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
`start_time` int(10) NOT NULL DEFAULT 0,
`end_time` int(10) NOT NULL DEFAULT 0,
`createtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
GO;
#发布积攒活动文章
CREATE TABLE IF NOT EXISTS act_article (
`id` int(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`act_id` int(8) NOT NULL DEFAULT 0,
`good_count` int(8) NOT NULL DEFAULT 0,
`user_id` int(8) NOT NULL DEFAULT 0,
`content` text,
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
GO;
#创建活动id和user索引
ALTER TABLE act_article ADD INDEX INDEX_ACT (act_id);
GO;
ALTER TABLE act_article ADD INDEX INDEX_USER (user_id);
GO;
#发布积攒活动文章图片
CREATE TABLE IF NOT EXISTS act_article_img (
`id` int(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`article_id` int(8) NOT NULL DEFAULT 0,
`img_url` varchar(200) DEFAULT '',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
GO;
#创建活动id
ALTER TABLE act_article_img ADD INDEX INDEX_ACT (article_id);
GO;
#发布积攒活动文章点赞
CREATE TABLE IF NOT EXISTS act_article_good (
`id` int(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`act_id` int(8) NOT NULL DEFAULT 0,
`article_id` int(8) NOT NULL DEFAULT 0,
`user_id` int(8) NOT NULL DEFAULT 0,
`ip` varchar(20) NOT NULL DEFAULT '',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
GO;
#创建活动id和ip索引
ALTER TABLE act_article_good ADD INDEX INDEX_ACT_IP (act_id, article_id, ip);
GO;