CREATE DATABASE idata;
USE idata;

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users`
(
    `id`              bigint unsigned NOT NULL AUTO_INCREMENT,
    `uid`             varchar(127)    NOT NULL COMMENT '用户ID',
    `openid`          varchar(255)    NOT NULL COMMENT '微信openid',
    `secret`          varchar(255)    NOT NULL COMMENT 'secret',
    `phone`           varchar(63)     NOT NULL COMMENT '手机号',
    `password`        varchar(255)    NOT NULL DEFAULT '' COMMENT '密码',
    `avatar`          varchar(255)    NOT NULL DEFAULT '' COMMENT '头像url',
    `name`            varchar(255)    NOT NULL DEFAULT '' COMMENT '昵称',
    `gender`          int             NOT NULL DEFAULT 0 COMMENT '性别',
    `score`           int             NOT NULL DEFAULT 0 COMMENT '金币数量',
    `vip`             int             NOT NULL DEFAULT 0 COMMENT 'VIP等级',
    `vip_expire_time` bigint          NOT NULL DEFAULT 0 COMMENT 'VIP到期时间戳',
    `api_opened`      bigint          NOT NULL DEFAULT 0 COMMENT 'Api开通情况',
    `create_time`     timestamp       NULL     DEFAULT CURRENT_TIMESTAMP,
    `update_time`     timestamp       NULL     DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`) USING BTREE,
    UNIQUE KEY `uid_unique` (`uid`) USING BTREE,
    UNIQUE KEY `phone_unique` (`phone`) USING BTREE,
    UNIQUE key `openid_unique` (`openid`) USING BTREE
) ENGINE = InnoDB
  AUTO_INCREMENT = 1
  DEFAULT CHARSET = utf8mb4;
-- ----------------------------
-- Records of accounts
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;

-- goctl model mysql datasource -url="root:Hawtech^666@tcp(gz-cynosdbmysql-grp-niaolcgt.sql.tencentcdb.com:26529)/idata" -table="*"  -dir="./dao" -c
