text: /*
  SQLyog Ultimate v13.1.1 (64 bit)
  MySQL - 8.0.23 : Database - coincola
  *********************************************************************
  */
  
  /*!40101 SET NAMES utf8 */;
  
  /*!40101 SET SQL_MODE=''*/;
  
  /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
  /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
  /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
  /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
  CREATE DATABASE /*!32312 IF NOT EXISTS*/`coincola` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
  
  USE `coincola`;
  
  /*Table structure for table `appkey` */
  
  CREATE TABLE `appkey` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'auto increase id',
    `user_id` bigint NOT NULL COMMENT 'user id',
    `app_id` varchar(512) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'app id',
    `app_key` varchar(512) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'app key',
    `app_secret` varchar(512) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'app secret',
    `app_reserve` text COLLATE utf8mb4_general_ci NOT NULL COMMENT 'app reserved content',
    `market_id` int NOT NULL COMMENT 'exchange market id (map to market table id column)',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time (auto update by database)',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  
  /*Data for the table `appkey` */
  
  /*Table structure for table `market` */
  
  CREATE TABLE `market` (
    `id` int NOT NULL AUTO_INCREMENT COMMENT 'market id (auto increase)',
    `name` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'market name (BINANCE,HUOBI,COINBASE...)',
    `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'deleted (0=false 1=true)',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time (auto update by database)',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  
  /*Data for the table `market` */
  
  insert  into `market`(`id`,`name`,`deleted`,`created_time`,`updated_time`) values 
  (1,'BINANCE',0,'2021-09-26 09:16:05','2021-09-26 09:16:05'),
  (2,'HUOBI',0,'2021-09-26 09:16:10','2021-09-26 09:16:10'),
  (3,'COINBASE',0,'2021-09-26 09:16:21','2021-09-26 09:16:31');
  
  /*Table structure for table `record` */
  
  CREATE TABLE `record` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'trade record id (auto increase)',
    `user_id` bigint NOT NULL COMMENT 'trade user id',
    `action` tinyint NOT NULL COMMENT 'trade action (1=sell 2=buy)',
    `symbol` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'trade symbol (BTC/USDT e.g)',
    `market_id` int NOT NULL COMMENT 'exchange market id (map to market table id column)',
    `strategy_id` bigint NOT NULL DEFAULT '0' COMMENT 'trade strategy (0=no any strategy)',
    `price` decimal(10,0) NOT NULL DEFAULT '0' COMMENT 'trade price',
    `fee` decimal(10,0) NOT NULL DEFAULT '0' COMMENT 'trade fee',
    `ok` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'is ok (0=false 1=true)',
    `error` text COLLATE utf8mb4_general_ci COMMENT 'error message',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time (auto create by database)',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time (auto update by database)',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  
  /*Data for the table `record` */
  
  /*Table structure for table `strategy` */
  
  CREATE TABLE `strategy` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'strategy id (auto increase)',
    `user_id` bigint NOT NULL COMMENT 'user id belong to',
    `market_id` int NOT NULL COMMENT 'exchange market id (map to market table id column)',
    `symbol` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'trade symbol (BTC/USDT e.g)',
    `price` decimal(10,0) NOT NULL DEFAULT '0' COMMENT 'trade price',
    `quantity` decimal(10,0) NOT NULL DEFAULT '0' COMMENT 'trade quantity',
    `action` tinyint NOT NULL COMMENT 'trade action (1=sell 2=buy)',
    `dead_line` bigint NOT NULL DEFAULT '0' COMMENT 'trade dead line (0=no limit)',
    `done` tinyint NOT NULL DEFAULT '0' COMMENT 'is done? (0=no 1=yes 2=deadline)',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time (auto create by database)',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'update time (auto update by database)',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  
  /*Data for the table `strategy` */
  
  /*Table structure for table `symbol` */
  
  CREATE TABLE `symbol` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id (auto increase)',
    `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'symbol name (BTC/USDT)',
    `market_id` int NOT NULL COMMENT 'exchange market id (map to market table id column)',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time (auto create by database)',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time (auto update by database)',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  
  /*Data for the table `symbol` */
  
  /*Table structure for table `user` */
  
  CREATE TABLE `user` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'user id (auto increase)',
    `name` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'user name',
    `password` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'password with MD5+SALT',
    `phone` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'cell phone number',
    `email` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'email address',
    `address` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'home address',
    `remark` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'remark',
    `deleted` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'is deleted (0=false 1=true)',
    `banned` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'is banned (0=false 1=true)',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time (auto update by database)',
    PRIMARY KEY (`id`),
    UNIQUE KEY `UNIQ_EMAIL` (`email`),
    UNIQUE KEY `UNIQ_PHONE` (`phone`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
  
  /*Data for the table `user` */
  
  /*Table structure for table `wallet` */
  
  CREATE TABLE `wallet` (
    `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'wallet id (auto increase)',
    `user_id` bigint NOT NULL COMMENT 'user id',
    `coin` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'coin name',
    `quantity` decimal(10,0) NOT NULL DEFAULT '0' COMMENT 'asset quantity',
    `market_id` int NOT NULL COMMENT 'exchange market id (map to market table id column)',
    `created_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
    `updated_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time (auto update by database)',
    PRIMARY KEY (`id`),
    UNIQUE KEY `UNIQ_USERID_COIN_MARKET` (`user_id`,`coin`,`market_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
  
  /*Data for the table `wallet` */
  
  /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
  /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
  /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
  /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
  