<?php
/**
 * https://www.besyun.com
 * BESCMS
 * 系统安装 Schema（规范化 DDL：Table::install_schema → 驱动 createTable）
 * 由 Control\Install / Init 显式 require 后交给安装门面执行，勿依赖副作用。
 */

return [
    'tables' => [
        'cron' => [
            'comment' => '任务管理',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT',
                'site' => 'int(10) NOT NULL COMMENT \'项目id\'',
                'type' => 'varchar(100) NOT NULL COMMENT \'类型\'',
                'value' => 'text NOT NULL COMMENT \'参数值\'',
                'status' => 'tinyint(1) unsigned NOT NULL COMMENT \'状态\'',
                'error' => 'text DEFAULT NULL COMMENT \'错误信息\'',
                'updatetime' => 'int(10) unsigned NOT NULL COMMENT \'执行时间\'',
                'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'写入时间\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `site` (`site`)',
                'KEY `type` (`type`)',
                'KEY `status` (`status`)',
                'KEY `updatetime` (`updatetime`)',
                'KEY `inputtime` (`inputtime`)',
            ],
        ],
        'admin' => [
            'comment' => '管理员表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
                'uid' => 'int(10) unsigned NOT NULL COMMENT \'管理员uid\'',
                'setting' => 'mediumtext DEFAULT NULL COMMENT \'相关配置\'',
                'usermenu' => 'text COMMENT \'自定义面板菜单，序列化数组格式\'',
                'history' => 'text COMMENT \'历史菜单，序列化数组格式\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'UNIQUE KEY `uid` (`uid`)',
            ],
        ],
        'admin_notice' => [
            'comment' => '后台提醒表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) NOT NULL AUTO_INCREMENT COMMENT \'id\'',
                'site' => 'int(5) NOT NULL COMMENT \'项目id\'',
                'type' => 'varchar(20) NOT NULL COMMENT \'提醒类型：系统、内容、会员、应用\'',
                'msg' => 'text NOT NULL COMMENT \'提醒内容说明\'',
                'uri' => 'varchar(100) NOT NULL COMMENT \'对应的URI\'',
                'to_rid' => 'varchar(100) NOT NULL COMMENT \'指定角色组\'',
                'to_uid' => 'varchar(100) NOT NULL COMMENT \'指定管理员\'',
                'status' => 'tinyint(1) NOT NULL COMMENT \'未处理0，1已查看，2处理中，3处理完成\'',
                'uid' => 'int(10) NOT NULL COMMENT \'申请人\'',
                'username' => 'varchar(100) NOT NULL COMMENT \'申请人\'',
                'op_uid' => 'int(10) NOT NULL COMMENT \'处理人\'',
                'op_username' => 'varchar(100) NOT NULL COMMENT \'处理人\'',
                'updatetime' => 'int(10) NOT NULL COMMENT \'处理时间\'',
                'inputtime' => 'int(10) NOT NULL COMMENT \'提醒时间\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `uri` (`uri`)',
                'KEY `site` (`site`)',
                'KEY `status` (`status`)',
                'KEY `uid` (`uid`)',
                'KEY `op_uid` (`op_uid`)',
                'KEY `to_uid` (`to_uid`)',
                'KEY `to_rid` (`to_rid`)',
                'KEY `updatetime` (`updatetime`)',
                'KEY `inputtime` (`inputtime`)',
            ],
        ],
        'admin_login' => [
            'comment' => '登录日志记录',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
                'uid' => 'mediumint(8) unsigned DEFAULT NULL COMMENT \'会员uid\'',
                'loginip' => 'varchar(50) NOT NULL COMMENT \'登录Ip\'',
                'logintime' => 'int(10) unsigned NOT NULL COMMENT \'登录时间\'',
                'useragent' => 'varchar(255) NOT NULL COMMENT \'客户端信息\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `uid` (`uid`)',
                'KEY `loginip` (`loginip`)',
                'KEY `logintime` (`logintime`)',
            ],
        ],
        'admin_menu' => [
            'comment' => '后台菜单表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
                'pid' => 'smallint(5) unsigned NOT NULL COMMENT \'上级菜单id\'',
                'name' => 'text NOT NULL COMMENT \'菜单语言名称\'',
                'site' => 'text NOT NULL COMMENT \'项目归属\'',
                'uri' => 'varchar(255) DEFAULT NULL COMMENT \'uri字符串\'',
                'url' => 'varchar(255) DEFAULT NULL COMMENT \'外链地址\'',
                'mark' => 'varchar(255) DEFAULT NULL COMMENT \'菜单标识\'',
                'hidden' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'是否隐藏\'',
                'icon' => 'varchar(255) DEFAULT NULL COMMENT \'图标标示\'',
                'displayorder' => 'int(5) DEFAULT NULL COMMENT \'排序值\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `list` (`pid`)',
                'KEY `displayorder` (`displayorder`)',
                'KEY `mark` (`mark`)',
                'KEY `hidden` (`hidden`)',
                'KEY `uri` (`uri`)',
            ],
        ],
        'admin_min_menu' => [
            'comment' => '后台简化菜单表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
                'pid' => 'smallint(5) unsigned NOT NULL COMMENT \'上级菜单id\'',
                'name' => 'text NOT NULL COMMENT \'菜单语言名称\'',
                'site' => 'text NOT NULL COMMENT \'项目归属\'',
                'uri' => 'varchar(255) DEFAULT NULL COMMENT \'uri字符串\'',
                'url' => 'varchar(255) DEFAULT NULL COMMENT \'外链地址\'',
                'mark' => 'varchar(255) DEFAULT NULL COMMENT \'菜单标识\'',
                'hidden' => 'tinyint(1) unsigned DEFAULT NULL COMMENT \'是否隐藏\'',
                'icon' => 'varchar(255) DEFAULT NULL COMMENT \'图标标示\'',
                'displayorder' => 'int(5) DEFAULT NULL COMMENT \'排序值\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `list` (`pid`)',
                'KEY `displayorder` (`displayorder`)',
                'KEY `mark` (`mark`)',
                'KEY `hidden` (`hidden`)',
                'KEY `uri` (`uri`)',
            ],
        ],
        'admin_role' => [
            'comment' => '后台角色权限表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) NOT NULL AUTO_INCREMENT',
                'site' => 'text NOT NULL COMMENT \'允许管理的项目，序列化数组格式\'',
                'name' => 'text NOT NULL COMMENT \'角色组语言名称\'',
                'system' => 'mediumtext NOT NULL COMMENT \'系统权限\'',
                'module' => 'mediumtext NOT NULL COMMENT \'模块权限\'',
                'application' => 'mediumtext NOT NULL COMMENT \'应用权限\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
            ],
        ],
        'admin_role_index' => [
            'comment' => '后台角色组分配表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) NOT NULL AUTO_INCREMENT',
                'uid' => 'mediumint(8) unsigned DEFAULT NULL COMMENT \'会员uid\'',
                'roleid' => 'mediumint(8) unsigned DEFAULT NULL COMMENT \'角色组id\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY (`uid`)',
                'KEY (`roleid`)',
            ],
        ],
        'admin_setting' => [
            'comment' => '系统属性参数表',
            'drop' => true,
            'fields' => [
                'name' => 'varchar(50) NOT NULL',
                'value' => 'mediumtext NOT NULL',
            ],
            'indexes' => [
                'PRIMARY KEY (`name`)',
            ],
        ],
        'mail_smtp' => [
            'comment' => '邮件账户表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
                'host' => 'varchar(255) NOT NULL',
                'user' => 'varchar(255) NOT NULL',
                'pass' => 'varchar(255) NOT NULL',
                'port' => 'mediumint(8) unsigned NOT NULL',
                'displayorder' => 'smallint(5) DEFAULT NULL',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY (`displayorder`)',
            ],
        ],
        'attachment' => [
            'comment' => '附件表',
            'drop' => true,
            'fields' => [
                'id' => 'mediumint(8) unsigned NOT NULL AUTO_INCREMENT',
                'uid' => 'mediumint(8) unsigned NOT NULL COMMENT \'会员id\'',
                'author' => 'varchar(50) NOT NULL COMMENT \'会员\'',
                'siteid' => 'mediumint(5) unsigned NOT NULL COMMENT \'项目id\'',
                'related' => 'varchar(50) NOT NULL COMMENT \'相关表标识\'',
                'tableid' => 'tinyint(1) unsigned NOT NULL DEFAULT \'0\' COMMENT \'附件副表id\'',
                'download' => 'mediumint(8) NOT NULL DEFAULT \'0\' COMMENT \'无用保留\'',
                'filesize' => 'int(10) unsigned NOT NULL COMMENT \'文件大小\'',
                'fileext' => 'varchar(20) NOT NULL COMMENT \'文件扩展名\'',
                'filemd5' => 'varchar(50) NOT NULL COMMENT \'文件md5值\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `uid` (`uid`)',
                'KEY `author` (`author`)',
                'KEY `relatedtid` (`related`)',
                'KEY `fileext` (`fileext`)',
                'KEY `filemd5` (`filemd5`)',
                'KEY `siteid` (`siteid`)',
            ],
        ],
        'attachment_remote' => [
            'comment' => '附件储存策略表',
            'drop' => true,
            'fields' => [
                'id' => 'tinyint(2) unsigned NOT NULL AUTO_INCREMENT',
                'type' => 'tinyint(2) NOT NULL COMMENT \'类型\'',
                'name' => 'varchar(50) NOT NULL COMMENT \'名称\'',
                'url' => 'varchar(255) NOT NULL COMMENT \'访问地址\'',
                'value' => 'text NOT NULL COMMENT \'参数值\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
            ],
        ],
        'attachment_data' => [
            'comment' => '附件已归档表',
            'drop' => true,
            'fields' => [
                'id' => 'mediumint(8) unsigned NOT NULL COMMENT \'附件id\'',
                'uid' => 'mediumint(8) unsigned NOT NULL DEFAULT \'0\' COMMENT \'会员id\'',
                'author' => 'varchar(50) NOT NULL COMMENT \'会员\'',
                'related' => 'varchar(50) NOT NULL COMMENT \'相关表标识\'',
                'filename' => 'varchar(255) NOT NULL DEFAULT \'\' COMMENT \'原文件名\'',
                'fileext' => 'varchar(20) NOT NULL COMMENT \'文件扩展名\'',
                'filesize' => 'int(10) unsigned NOT NULL DEFAULT \'0\' COMMENT \'文件大小\'',
                'attachment' => 'varchar(255) NOT NULL DEFAULT \'\' COMMENT \'服务器路径\'',
                'remote' => 'tinyint(2) unsigned NOT NULL DEFAULT \'0\' COMMENT \'附件策略id\'',
                'attachinfo' => 'text NOT NULL COMMENT \'附件信息\'',
                'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'入库时间\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `inputtime` (`inputtime`)',
                'KEY `fileext` (`fileext`)',
                'KEY `remote` (`remote`)',
                'KEY `author` (`author`)',
                'KEY `uid` (`uid`)',
            ],
        ],
        'attachment_unused' => [
            'comment' => '未使用的附件表',
            'drop' => true,
            'fields' => [
                'id' => 'mediumint(8) unsigned NOT NULL COMMENT \'附件id\'',
                'uid' => 'mediumint(8) unsigned NOT NULL DEFAULT \'0\' COMMENT \'会员id\'',
                'author' => 'varchar(50) NOT NULL COMMENT \'会员\'',
                'siteid' => 'mediumint(5) unsigned NOT NULL COMMENT \'项目id\'',
                'filename' => 'varchar(255) NOT NULL DEFAULT \'\' COMMENT \'原文件名\'',
                'fileext' => 'varchar(20) NOT NULL COMMENT \'文件扩展名\'',
                'filesize' => 'int(10) unsigned NOT NULL DEFAULT \'0\' COMMENT \'文件大小\'',
                'attachment' => 'varchar(255) NOT NULL DEFAULT \'\' COMMENT \'服务器路径\'',
                'remote' => 'tinyint(2) unsigned NOT NULL DEFAULT \'0\' COMMENT \'附件策略id\'',
                'attachinfo' => 'text NOT NULL COMMENT \'附件信息\'',
                'inputtime' => 'int(10) unsigned NOT NULL COMMENT \'入库时间\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `uid` (`uid`)',
                'KEY `inputtime` (`inputtime`)',
                'KEY `fileext` (`fileext`)',
                'KEY `remote` (`remote`)',
                'KEY `author` (`author`)',
            ],
        ],
        'field' => [
            'comment' => '字段表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
                'name' => 'text NOT NULL COMMENT \'字段别名语言\'',
                'fieldname' => 'varchar(50) NOT NULL COMMENT \'字段名称\'',
                'fieldtype' => 'varchar(50) NOT NULL COMMENT \'字段类型\'',
                'relatedid' => 'smallint(5) unsigned NOT NULL COMMENT \'相关id\'',
                'relatedname' => 'varchar(50) NOT NULL COMMENT \'相关表\'',
                'isedit' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'是否可修改\'',
                'ismain' => 'tinyint(1) unsigned NOT NULL COMMENT \'是否主表\'',
                'issystem' => 'tinyint(1) unsigned NOT NULL COMMENT \'是否系统表\'',
                'ismember' => 'tinyint(1) unsigned NOT NULL COMMENT \'是否会员可见\'',
                'issearch' => 'tinyint(1) unsigned NOT NULL DEFAULT \'1\' COMMENT \'是否可搜索\'',
                'disabled' => 'tinyint(1) unsigned NOT NULL COMMENT \'禁用？\'',
                'setting' => 'mediumtext NOT NULL COMMENT \'配置信息\'',
                'displayorder' => 'int(5) NOT NULL COMMENT \'排序\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `list` (`relatedid`,`disabled`,`issystem`)',
            ],
        ],
        'linkage' => [
            'comment' => '联动菜单表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
                'name' => 'varchar(255) NOT NULL COMMENT \'菜单名称\'',
                'type' => 'tinyint(1) unsigned NOT NULL',
                'code' => 'char(20) NOT NULL',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'UNIQUE KEY `code` (`code`)',
                'KEY `module` (`id`)',
            ],
        ],
        'linkage_data_1' => [
            'comment' => '联动菜单数据表',
            'drop' => true,
            'fields' => [
                'id' => 'mediumint(8) unsigned NOT NULL AUTO_INCREMENT',
                'site' => 'mediumint(5) unsigned NOT NULL COMMENT \'项目id\'',
                'pid' => 'mediumint(8) unsigned NOT NULL DEFAULT \'0\' COMMENT \'上级id\'',
                'pids' => 'varchar(255) DEFAULT NULL COMMENT \'所有上级id\'',
                'name' => 'varchar(30) NOT NULL COMMENT \'栏目名称\'',
                'cname' => 'varchar(30) NOT NULL COMMENT \'别名\'',
                'child' => 'tinyint(1) unsigned DEFAULT \'0\' COMMENT \'是否有下级\'',
                'hidden' => 'tinyint(1) unsigned DEFAULT \'0\' COMMENT \'前端隐藏\'',
                'childids' => 'text DEFAULT NULL COMMENT \'下级所有id\'',
                'displayorder' => 'mediumint(8) DEFAULT \'0\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `cname` (`cname`)',
                'KEY `hidden` (`hidden`)',
                'KEY `list` (`site`,`displayorder`)',
            ],
        ],
        'site' => [
            'comment' => '项目表',
            'drop' => true,
            'fields' => [
                'id' => 'smallint(5) unsigned NOT NULL AUTO_INCREMENT',
                'name' => 'varchar(255) NOT NULL COMMENT \'项目名称\'',
                'domain' => 'varchar(50) NOT NULL COMMENT \'项目域名\'',
                'setting' => 'mediumtext NOT NULL COMMENT \'项目配置\'',
                'disabled' => 'tinyint(1) NOT NULL DEFAULT \'0\' COMMENT \'禁用\'',
                'displayorder' => 'smallint(5) DEFAULT \'0\' COMMENT \'排序\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `disabled` (`disabled`)',
                'KEY `displayorder` (`displayorder`)',
            ],
        ],
        'member' => [
            'comment' => '会员表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
                'email' => 'varchar(50) NOT NULL DEFAULT \'\' COMMENT \'邮箱地址\'',
                'phone' => 'varchar(20) NOT NULL COMMENT \'手机号码\'',
                'username' => 'varchar(50) NOT NULL DEFAULT \'\' COMMENT \'用户名\'',
                'password' => 'varchar(50) NOT NULL DEFAULT \'\' COMMENT \'加密密码\'',
                'login_attr' => 'varchar(100) NOT NULL DEFAULT \'\' COMMENT \'登录附加验证字符\'',
                'salt' => 'varchar(50) NOT NULL COMMENT \'随机加密码\'',
                'name' => 'varchar(50) NOT NULL COMMENT \'姓名\'',
                'money' => 'decimal(10,2) unsigned NOT NULL COMMENT \'RMB\'',
                'freeze' => 'decimal(10,2) unsigned NOT NULL COMMENT \'冻结RMB\'',
                'spend' => 'decimal(10,2) unsigned NOT NULL COMMENT \'消费RMB总额\'',
                'score' => 'int(10) unsigned NOT NULL COMMENT \'积分\'',
                'experience' => 'int(10) unsigned NOT NULL COMMENT \'经验值\'',
                'regip' => 'varchar(200) NOT NULL COMMENT \'注册ip\'',
                'regtime' => 'int(10) unsigned NOT NULL COMMENT \'注册时间\'',
                'randcode' => 'mediumint(6) unsigned NOT NULL COMMENT \'随机验证码\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
                'KEY `username` (`username`)',
                'KEY `email` (`email`)',
                'KEY `phone` (`phone`)',
            ],
        ],
        'member_data' => [
            'comment' => '会员表',
            'drop' => true,
            'fields' => [
                'id' => 'int(10) unsigned NOT NULL AUTO_INCREMENT',
                'is_admin' => 'tinyint(1) unsigned DEFAULT 0 COMMENT \'是否是管理员\'',
                'is_lock' => 'tinyint(1) unsigned DEFAULT 0 COMMENT \'账号锁定标识\'',
                'is_verify' => 'tinyint(1) unsigned DEFAULT 0 COMMENT \'审核标识\'',
                'is_mobile' => 'tinyint(1) unsigned DEFAULT 0 COMMENT \'手机认证标识\'',
                'is_email' => 'tinyint(1) unsigned DEFAULT 0 COMMENT \'邮箱认证标识\'',
                'is_avatar' => 'tinyint(1) unsigned DEFAULT 0 COMMENT \'头像上传标识\'',
                'is_complete' => 'tinyint(1) unsigned DEFAULT 0 COMMENT \'完善资料标识\'',
            ],
            'indexes' => [
                'PRIMARY KEY (`id`)',
            ],
        ],
    ],
    'seeds' => [
        [
            'table' => 'admin_role',
            'data' => [
                'id' => 1,
                'site' => '',
                'name' => '超级管理员',
                'system' => '',
                'module' => '',
                'application' => '',
            ],
        ],
        [
            'table' => 'admin_role',
            'data' => [
                'id' => 2,
                'site' => '',
                'name' => '编辑员',
                'system' => '',
                'module' => '',
                'application' => '',
            ],
        ],
        [
            'table' => 'linkage',
            'data' => [
                'id' => 1,
                'name' => '中国地区',
                'type' => 0,
                'code' => 'address',
            ],
        ],
        [
            'table' => 'linkage_data_1',
            'data' => [
                'id' => 1,
                'site' => 1,
                'pid' => 0,
                'pids' => 0,
                'name' => '北京',
                'cname' => 'bj',
                'child' => 0,
                'hidden' => 0,
                'childids' => 1,
                'displayorder' => 0,
            ],
        ],
        [
            'table' => 'linkage_data_1',
            'data' => [
                'id' => 2,
                'site' => 1,
                'pid' => 0,
                'pids' => 0,
                'name' => '成都',
                'cname' => 'cd',
                'child' => 0,
                'hidden' => 0,
                'childids' => 2,
                'displayorder' => 0,
            ],
        ],
    ],
];
