begin;

-- CREATE TABLE `t_crystal` (
--   `idx` bigint(20) NOT NULL AUTO_INCREMENT,
--   `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
--   `address` varchar(60) COMMENT 'address',
--   `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
--   `item_num` bigint NOT NULL DEFAULT '0' COMMENT '道具数量',
--   `createtime` int(11) NOT NULL COMMENT '创建时间',
--   `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
--   PRIMARY KEY (`idx`),
--   UNIQUE KEY `account_id_item_id` (`account_id`, `item_id`),
--   KEY `account_id` (`account_id`)
-- ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;


CREATE TABLE `t_crystal_exchange_record` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT,
  `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
  `address` varchar(60) COMMENT 'address',
  `period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期',
  `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
  `item_num` bigint NOT NULL DEFAULT '0' COMMENT '道具数量',
  `createtime` int(11) NOT NULL COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

CREATE TABLE `t_power_exchange_record` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT,
  `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
  `address` varchar(60) COMMENT 'address',
  `period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期',
  `item_num1` int(11)  NOT NULL DEFAULT '0' COMMENT '晶体道具260001兑换算力数量',
  `item_num2` int(11)  NOT NULL DEFAULT '0' COMMENT '晶体道具260002兑换算力数量',
  `item_num3` int(11)  NOT NULL DEFAULT '0' COMMENT '晶体道具260003兑换算力数量',
  `item_num4` int(11)  NOT NULL DEFAULT '0' COMMENT '晶体道具260004兑换算力数量',
  `total_num` double NOT NULL DEFAULT '0' COMMENT '算力总量',
  `createtime` int(11) NOT NULL COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

CREATE TABLE `t_computing_power_period` (
   `idx` bigint(20) NOT NULL AUTO_INCREMENT,
   `period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期',
   `total_num` varchar(60) COMMENT '全服算力总量',
   `createtime` int(11) NOT NULL COMMENT '创建时间',
   `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
   PRIMARY KEY (`idx`),
   UNIQUE KEY `period` (`period`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

CREATE TABLE `t_hash_rate_reward` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT,
  `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
  `address` varchar(60) COMMENT 'address',
  `period` int(11) NOT NULL DEFAULT '0' COMMENT '第几期',
  `power` varchar(60) COMMENT '算力',
  `reward_cec` varchar(60) COMMENT 'reward cec',
  `reward1` int(11) NOT NULL DEFAULT '0' COMMENT '第1周奖励',
  `reward2` int(11) NOT NULL DEFAULT '0' COMMENT '第2周奖励',
  `reward3` int(11) NOT NULL DEFAULT '0' COMMENT '第3周奖励',
  `reward4` int(11) NOT NULL DEFAULT '0' COMMENT '第4周奖励',
  `txHash1` varchar(60) NOT NULL DEFAULT '' COMMENT '地址1',
  `txHash2` varchar(60) NOT NULL DEFAULT '' COMMENT '地址2',
  `txHash3` varchar(60) NOT NULL DEFAULT '' COMMENT '地址3',
  `txHash4` varchar(60) NOT NULL DEFAULT '' COMMENT '地址4',

  `createtime` int(11) NOT NULL COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  KEY `account_id` (`account_id`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;

CREATE TABLE `t_staking` (
  `idx` bigint(20) NOT NULL AUTO_INCREMENT,
  `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
  `address` varchar(60) NOT NULL DEFAULT '' COMMENT 'address',
  `order_id` varchar(60) COMMENT 'order_id',
  `token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
  `token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片 6:荣誉 7:徽章',
  `net_id` bigint NOT NULL DEFAULT '0' COMMENT 'net_id',
  `contract_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'contract_address',
  `stacked_num` varchar(60) NOT NULL DEFAULT '' COMMENT 'stacked_num',
  `start_time` bigint NOT NULL DEFAULT '0' COMMENT '质押开始时间',
  `stake_time` bigint NOT NULL DEFAULT '0' COMMENT '质押结束时间',
  `redeem_time` bigint NOT NULL DEFAULT '0' COMMENT '赎回时间',
  `status` int(11) NOT NULL COMMENT '0:质押中 1:已解押',
  `txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash',
  `nft_type` int(11) NOT NULL COMMENT '',
  `nft_reward` double NOT NULL DEFAULT '0' COMMENT '利息',
  `createtime` int(11) NOT NULL COMMENT '创建时间',
  `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
  PRIMARY KEY (`idx`),
  UNIQUE KEY `unikey1` (`token_id`, `contract_address`, `net_id`, `start_time`),
  UNIQUE KEY `unikey2` (`token_id`, `contract_address`, `net_id`, `order_id`),
  KEY `address` (`address`)
) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8;

alter table t_bc_order add column `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT 'currency_name';

alter table t_mall add column `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT 'currency_name';

insert into version (version) values(2023081601);

commit;
