CREATE DATABASE `cashbook` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

-- cashbook.book definition
CREATE TABLE `book` (
  `id` int NOT NULL AUTO_INCREMENT,
  `book_name` varchar(200) NOT NULL,
  `create_time` timestamp NOT NULL,
  `update_time` timestamp NOT NULL,
  `author_id` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '账本创建者',
  `is_del` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='账本信息';

-- cashbook.record definition
CREATE TABLE `record` (
  `id` int NOT NULL AUTO_INCREMENT,
  `book_id` varchar(100) NOT NULL,
  `create_time` timestamp NOT NULL COMMENT '创建流程',
  `update_time` timestamp NOT NULL COMMENT '更新时间',
  `total_fee` decimal(15,2) NOT NULL,
  `type_id` int NOT NULL,
  `author_id` varchar(300) NOT NULL,
  `remark` LONGTEXT DEFAULT NULL,
  `time` timestamp NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='账本记录';

-- cashbook.types definition
CREATE TABLE `types` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(300) NOT NULL,
  `record_id` int DEFAULT NULL,
  `book_id` int NOT NULL,
  `create_time` timestamp NOT NULL,
  `update_time` timestamp NOT NULL,
  `author_id` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- cashbook.authors definition
CREATE TABLE `authors` (
  `id` int NOT NULL AUTO_INCREMENT,
  `name` varchar(200) NOT NULL COMMENT '昵称',
  `login_type` int NOT NULL COMMENT '1: 手机号 2: 邮箱',
  `email` varchar(100) NOT NULL,
  `mobile` varchar(100) NOT NULL,
  `password` varchar(300) NOT NULL COMMENT 'md5加密',
  `update_time` timestamp NOT NULL,
  `user_id` varchar(300) NOT NULL,
  `create_time` timestamp NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `authors_unique` (`email`),
  UNIQUE KEY `authors_unique_1` (`mobile`),
  UNIQUE KEY `authors_unique_2` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- cashbook.files definition
CREATE TABLE `files` (
  `id` int NOT NULL AUTO_INCREMENT,
  `md5` varchar(300) NOT NULL,
  `mimetype` varchar(300) NOT NULL,
  `size` int NOT NULL,
  `name` varchar(300) DEFAULT NULL,
  `create_time` timestamp NOT NULL,
  `update_time` timestamp NOT NULL,
  `author` varchar(300) DEFAULT NULL COMMENT '账本创建者',
  `is_del` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


-- cashbook.record_files definition
CREATE TABLE `record_files` (
  `id` int NOT NULL AUTO_INCREMENT,
  `file_id` varchar(300) NOT NULL,
  `record_id` varchar(300) NOT NULL,
  `book_id` varchar(300) NOT NULL,
  `author_id` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `create_time` timestamp NOT NULL,
  `update_time` timestamp NOT NULL,
  PRIMARY KEY (`id`)
-- ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- cashbook.more_record definition
CREATE TABLE `more_record` (
  `id` int NOT NULL AUTO_INCREMENT,
  `book_id` varchar(100) NOT NULL,
  `create_time` TIMESTAMP NOT NULL COMMENT '创建流程',
  `update_time` TIMESTAMP NOT NULL COMMENT '更新时间',
  `author_id` varchar(300) NOT NULL,
  `name` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `more_id` varchar(300) NOT NULL,
  `remark` longtext,
  `total_fee` decimal(15,2) NOT NULL,
  `start_time` TIMESTAMP NOT NULL,
  `end_time` TIMESTAMP NOT NULL,
  `type_id` int NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `more_record_unique` (`more_id`)
) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='更多账本记录';





-- -- cashbook.more_record definition
-- CREATE TABLE `pc_types` (
--   `id` int NOT NULL AUTO_INCREMENT,
--   `book_id` varchar(100) NOT NULL,
--   `create_time` TIMESTAMP NOT NULL COMMENT '创建流程',
--   `update_time` TIMESTAMP NOT NULL COMMENT '更新时间',
--   `author_id` varchar(300) NOT NULL,
--   `name` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
--   `more_id` varchar(300) NOT NULL,
--   `remark` longtext,
--   `total_fee` decimal(15,2) NOT NULL,
--   `start_time` TIMESTAMP NOT NULL,
--   `end_time` TIMESTAMP NOT NULL,
--   `type_id` int NOT NULL,
--   PRIMARY KEY (`id`),
--   UNIQUE KEY `more_record_unique` (`more_id`)
-- ) ENGINE=InnoDB AUTO_INCREMENT=25 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='更多账本记录';
