_migration.sql
1.56 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
/*
author: feng.chen@yoho.cn
date: 2017-06-27 11:25:29
comment: 初始化
*/
#注意:GO;分割执行块
#活动主表
CREATE TABLE IF NOT EXISTS activity (
`id` int(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
`title` varchar(100) NOT NULL,
`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,
`user_name` varchar(200) DEFAULT '',
`user_avatar` varchar(200) DEFAULT '',
`content` text,
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) DEFAULT CHARSET=utf8;
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;
#发布积攒活动文章点赞
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;