· 7 years ago · Sep 18, 2018, 01:24 PM
1SET NAMES utf8;
2SET FOREIGN_KEY_CHECKS = 0;
3
4-- ----------------------------
5-- Table structure for `component`
6-- ----------------------------
7DROP TABLE IF EXISTS `component`;
8CREATE TABLE `component` (
9 `_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
10 `uuid` varchar(40) DEFAULT NULL,
11 `name` varchar(100) DEFAULT NULL,
12 `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
13 `updated_at` timestamp NULL DEFAULT NULL,
14 `deleted_at` timestamp NULL DEFAULT NULL,
15 PRIMARY KEY (`_id`),
16 KEY `unique` (`uuid`) USING BTREE,
17 KEY `search` (`name`) USING BTREE
18) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
19
20-- ----------------------------
21-- Table structure for `product`
22-- ----------------------------
23DROP TABLE IF EXISTS `product`;
24CREATE TABLE `product` (
25 `_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '_ID,内部自增编å·',
26 `uuid` varchar(40) DEFAULT NULL,
27 `code` varchar(6) DEFAULT NULL,
28 `name` varchar(15) DEFAULT NULL,
29 `category` varchar(15) DEFAULT NULL,
30 `price` decimal(4,2) DEFAULT NULL,
31 `created_at` datetime DEFAULT NULL,
32 `updated_at` datetime DEFAULT NULL,
33 `deleted_at` datetime DEFAULT NULL,
34 PRIMARY KEY (`_id`),
35 UNIQUE KEY `unique_product_in_category` (`name`,`category`) USING BTREE,
36 KEY `code` (`code`),
37 KEY `uuid` (`uuid`)
38) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
39
40-- ----------------------------
41-- Table structure for `product_component`
42-- ----------------------------
43DROP TABLE IF EXISTS `product_component`;
44CREATE TABLE `product_component` (
45 `_id` int(11) NOT NULL AUTO_INCREMENT,
46 `uuid` varchar(40) DEFAULT NULL,
47 `product_uuid` varchar(40) DEFAULT NULL,
48 `component_uuid` varchar(40) DEFAULT NULL,
49 `created_at` timestamp NULL DEFAULT NULL,
50 `updated_at` timestamp NULL DEFAULT NULL,
51 `deleted_at` timestamp NULL DEFAULT NULL,
52 PRIMARY KEY (`_id`),
53 KEY `unique` (`product_uuid`,`component_uuid`) USING BTREE,
54 KEY `foreign` (`component_uuid`) USING BTREE,
55 CONSTRAINT `foreign_component` FOREIGN KEY (`component_uuid`) REFERENCES `component` (`uuid`) ON DELETE SET NULL ON UPDATE SET NULL,
56 CONSTRAINT `foreign_product` FOREIGN KEY (`product_uuid`) REFERENCES `product` (`uuid`) ON DELETE SET NULL ON UPDATE SET NULL
57) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
58
59-- ----------------------------
60-- Table structure for `user`
61-- ----------------------------
62DROP TABLE IF EXISTS `user`;
63CREATE TABLE `user` (
64 `_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '_ID,内部自增编å·',
65 `uuid` varchar(40) DEFAULT NULL,
66 `name` varchar(32) DEFAULT NULL,
67 `password` varchar(64) DEFAULT NULL,
68 `salt` varchar(64) DEFAULT NULL,
69 `created_at` datetime DEFAULT NULL,
70 `updated_at` datetime DEFAULT NULL,
71 `deleted_at` datetime DEFAULT NULL,
72 PRIMARY KEY (`_id`),
73 KEY `uuid` (`uuid`)
74) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
75
76SET FOREIGN_KEY_CHECKS = 1;