_migration.sql 1.56 KB
/*
    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;

#创建活动idip索引
ALTER TABLE act_article_good ADD INDEX INDEX_ACT_IP (act_id, article_id, ip);
GO;