<?php
$rt = \Phpcmf\Service::M('table')->install_schema([
    'tables' => [
        'app_weixin' => [
            'comment' => '多公众号表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'name' => 'varchar(200) NOT NULL COMMENT \'公众号名称\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
            ],
        ],
        'weixin' => [
            'comment' => '微信配置',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'Id\'',
                'name' => 'varchar(100) NOT NULL COMMENT \'表名称\'',
                'value' => 'text NOT NULL COMMENT \'字段配置项目\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'UNIQUE KEY `name` (`name`)',
            ],
        ],
        'weixin_follow' => [
            'comment' => '微信粉丝同步表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'openid' => 'varchar(255) NOT NULL COMMENT \'唯一id\'',
                'status' => 'tinyint(1) NOT NULL',
                'uid' => 'int(10) NOT NULL',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `uid` (`uid`)',
                'KEY `status` (`status`)',
                'KEY `openid` (`openid`)',
            ],
        ],
        'weixin_group' => [
            'comment' => '微信粉丝分组表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'tag' => 'int(10) NOT NULL COMMENT \'微信TagId\'',
                'name' => 'varchar(100) NOT NULL COMMENT \'标签名称\'',
                'count' => 'int(10) NOT NULL COMMENT \'粉丝人数\'',
                'groupid' => 'int(10) NOT NULL COMMENT \'用户组id\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `tag` (`tag`)',
                'KEY `groupid` (`groupid`)',
            ],
        ],
        'weixin_user' => [
            'comment' => '微信粉丝表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'uid' => 'int(10) unsigned DEFAULT NULL COMMENT \'会员id\'',
                'username' => 'varchar(100) NOT NULL COMMENT \'会员名\'',
                'groupids' => 'varchar(100) NOT NULL COMMENT \'标签组id值\'',
                'openid' => 'varchar(50) NOT NULL COMMENT \'唯一id\'',
                'nickname' => 'varchar(255) NOT NULL COMMENT \'微信昵称\'',
                'sex' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'性别\'',
                'city' => 'varchar(30) DEFAULT NULL COMMENT \'城市\'',
                'country' => 'varchar(30) DEFAULT NULL COMMENT \'国家\'',
                'province' => 'varchar(30) DEFAULT NULL COMMENT \'省\'',
                'headimgurl' => 'varchar(255) DEFAULT NULL COMMENT \'头像地址\'',
                'unionid' => 'varchar(255) DEFAULT NULL COMMENT \'绑定账号\'',
                'remark' => 'varchar(255) DEFAULT NULL COMMENT \'对粉丝的备注\'',
                'subscribe' => 'int(10) unsigned NOT NULL COMMENT \'关注时间\'',
                'subscribe_time' => 'int(10) unsigned NOT NULL COMMENT \'最近时间\'',
                'content' => 'text NOT NULL COMMENT \'字段\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'UNIQUE KEY `openid` (`openid`)',
                'KEY `subscribe` (`subscribe`)',
                'KEY `subscribe_time` (`subscribe_time`)',
            ],
        ],
        'weixin_menu' => [
            'comment' => '微信自定义菜单表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'pid' => 'int(10) NOT NULL COMMENT \'父id\'',
                'name' => 'varchar(255) NOT NULL COMMENT \'菜单名称\'',
                'type' => 'varchar(20) NOT NULL COMMENT \'菜单类型\'',
                'value' => 'text NOT NULL COMMENT \'执行值\'',
                'displayorder' => 'int(10) NOT NULL COMMENT \'排序值\'',
                'gid' => 'int(10) NOT NULL COMMENT \'标签组id\'',
                'menuid' => 'int(10) NOT NULL COMMENT \'个性菜单id\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `pid` (`pid`)',
                'KEY `displayorder` (`displayorder`)',
                'KEY `gid` (`gid`)',
            ],
        ],
        'weixin_content' => [
            'comment' => '微信素材内容表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'tid' => 'varchar(20) NOT NULL COMMENT \'素材类型\'',
                'title' => 'varchar(255) NOT NULL COMMENT \'标题\'',
                'content' => 'text NOT NULL COMMENT \'内容值数组\'',
                'media_id' => 'varchar(255) NOT NULL COMMENT \'微信media_id\'',
                'publish_id' => 'varchar(255) NOT NULL COMMENT \'publish_id\'',
                'article_id' => 'varchar(255) NOT NULL COMMENT \'article_id\'',
                'status' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'\'',
                'nums' => 'tinyint(2) unsigned DEFAULT NULL COMMENT \'\'',
                'inputtime' => 'int(10) NOT NULL COMMENT \'录入时间\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `inputtime` (`inputtime`)',
            ],
        ],
        'weixin_media_id' => [
            'comment' => '微信素材多媒体id表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'file' => 'varchar(255) NOT NULL COMMENT \'文件编码\'',
                'media_id' => 'varchar(255) NOT NULL COMMENT \'微信media_id\'',
                'url' => 'varchar(255) NOT NULL COMMENT \'对应地址\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `file` (`file`)',
            ],
        ],
        'weixin_send' => [
            'comment' => '微信客服消息发布表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'cid' => 'int(10) NOT NULL COMMENT \'cid\'',
                'openid' => 'varchar(255) NOT NULL COMMENT \'openid\'',
                'content' => 'text NOT NULL COMMENT \'内容值数组\'',
                'status' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'状态1成功，2失败，0未发送\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `cid` (`cid`)',
            ],
        ],
        'weixin_message' => [
            'comment' => '微信消息记录表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'tid' => 'varchar(20) NOT NULL COMMENT \'消息类型\'',
                'userid' => 'int(10) NOT NULL COMMENT \'用户id\'',
                'openid' => 'varchar(255) NOT NULL COMMENT \'openid\'',
                'nickname' => 'varchar(255) NOT NULL COMMENT \'昵称\'',
                'headimgurl' => 'varchar(255) NOT NULL COMMENT \'头像\'',
                'content' => 'text NOT NULL COMMENT \'消息内容\'',
                'file' => 'text NOT NULL COMMENT \'xiazia\'',
                'status' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'状态1更新，0未更新\'',
                'inputtime' => 'int(10) NOT NULL COMMENT \'录入时间\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `openid` (`openid`)',
                'KEY `userid` (`userid`)',
                'KEY `nickname` (`nickname`)',
                'KEY `inputtime` (`inputtime`)',
            ],
        ],
        'weixin_template' => [
            'comment' => '微信模板消息记录表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'title' => 'varchar(200) NOT NULL COMMENT \'主题\'',
                'groupid' => 'int(10) NOT NULL COMMENT \'发送标签组\'',
                'counts' => 'int(10) NOT NULL COMMENT \'发送数\'',
                'content' => 'text NOT NULL COMMENT \'消息内容\'',
                'template' => 'varchar(200) NOT NULL COMMENT \'模板ID\'',
                'url' => 'varchar(200) NOT NULL COMMENT \'对应url\'',
                'color' => 'varchar(200) NOT NULL COMMENT \'主题颜色\'',
                'inputtime' => 'int(10) NOT NULL COMMENT \'录入时间\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `inputtime` (`inputtime`)',
            ],
        ],
        'weixin_reply' => [
            'comment' => '微信素材自动回复表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'tid' => 'varchar(20) NOT NULL COMMENT \'素材类型\'',
                'title' => 'varchar(255) NOT NULL COMMENT \'规则名称\'',
                'keyword' => 'varchar(255) NOT NULL COMMENT \'关键字\'',
                'content' => 'text NOT NULL COMMENT \'内容值数组\'',
                'counts' => 'int(10) NOT NULL COMMENT \'命中次数\'',
                'displayorder' => 'int(10) NOT NULL COMMENT \'权重值\'',
                'updatetime' => 'int(10) NOT NULL COMMENT \'最近命中时间\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `keyword` (`keyword`)',
                'KEY `displayorder` (`displayorder`)',
                'KEY `updatetime` (`updatetime`)',
            ],
        ],
    ],
    'seeds' => [],
]);
if (empty($rt['code'])) {
    log_message('error', 'Weixin install_schema: '.($rt['msg'] ?? ''));
}
