<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="cn.skcks.matrix.v2.orm.mybatis.operation.OperateTableMapper">
    <update id="createUserTable">
        CREATE TABLE IF NOT EXISTS `user`
        (
            `id`           bigint                                                        NOT NULL,
            `user_name`    varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
            `password`     varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '加密后的密码',
            `salt`         varchar(255) COLLATE utf8mb4_general_ci                       NOT NULL COMMENT '加密密钥',
            `email`        varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
            `phone_number` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
            `description`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
            `create_time`  datetime                                                      NOT NULL,
            `update_time`  datetime                                                      NOT NULL,
            PRIMARY KEY (`id`)
        ) ENGINE = InnoDB
          DEFAULT CHARSET = utf8mb4
          COLLATE = utf8mb4_general_ci;
    </update>

    <update id="createRoleTable">
        CREATE TABLE IF NOT EXISTS `role`
        (
            `id`        bigint                                                        NOT NULL,
            `role`      varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '角色',
            `name`      varchar(255) COLLATE utf8mb4_general_ci                       NOT NULL COMMENT '角色名',
            `system_id` varchar(255) COLLATE utf8mb4_general_ci                       NOT NULL COMMENT '所属系统',
            `active`    tinyint(1)                                                    NOT NULL,
            PRIMARY KEY (`id`)
        ) ENGINE = InnoDB
          DEFAULT CHARSET = utf8mb4
          COLLATE = utf8mb4_general_ci;
    </update>

    <update id="createLocationRecordTable">
        CREATE TABLE IF NOT EXISTS `location_record` (
                                                         `id` varchar(255) NOT NULL,
                                                         `callback_time` datetime DEFAULT NULL,
                                                         `location_time` datetime DEFAULT NULL,
                                                         `location_type` int DEFAULT NULL,
                                                         `latitude` double DEFAULT NULL,
                                                         `longitude` double DEFAULT NULL,
                                                         `accuracy` double DEFAULT NULL,
                                                         `altitude` double DEFAULT NULL,
                                                         `bearing` double DEFAULT NULL,
                                                         `speed` double DEFAULT NULL,
                                                         `country` varchar(255) DEFAULT NULL,
                                                         `province` varchar(255) DEFAULT NULL,
                                                         `city` varchar(255) DEFAULT NULL,
                                                         `district` varchar(255) DEFAULT NULL,
                                                         `street` varchar(255) DEFAULT NULL,
                                                         `street_number` varchar(255) DEFAULT NULL,
                                                         `city_code` varchar(255) DEFAULT NULL,
                                                         `ad_code` varchar(255) DEFAULT NULL,
                                                         `address` varchar(255) DEFAULT NULL,
                                                         `description` varchar(255) DEFAULT NULL,
                                                         `user_id` bigint NOT NULL,
                                                         PRIMARY KEY (`id`)
        ) ENGINE=InnoDB
          DEFAULT CHARSET = utf8mb4
          COLLATE = utf8mb4_general_ci;
    </update>
</mapper>
