mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 13:09:19 +08:00
refactor: 拆分数据库sql设计文件
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
-- ========================================
|
||||
-- 组织-部门域设计
|
||||
-- org_department / org_department_member
|
||||
-- ========================================
|
||||
|
||||
-- ========================================
|
||||
-- 部门表
|
||||
-- ========================================
|
||||
DROP TABLE IF EXISTS `org_department`;
|
||||
CREATE TABLE `org_department` (
|
||||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '部门 id',
|
||||
`name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT '部门名称',
|
||||
`parent_id` bigint UNSIGNED NULL DEFAULT NULL COMMENT '部门父级 id',
|
||||
`company_id` bigint UNSIGNED NOT NULL COMMENT '公司 id',
|
||||
`remark` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '描述',
|
||||
`status` int NOT NULL DEFAULT 1 COMMENT '状态',
|
||||
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`create_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '创建人',
|
||||
`update_by` bigint UNSIGNED NULL DEFAULT NULL COMMENT '更新人',
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
INDEX `fk_org_department_parent`(`parent_id` ASC) USING BTREE,
|
||||
INDEX `fk_org_department_company`(`company_id` ASC) USING BTREE,
|
||||
INDEX `fk_org_department_creator`(`create_by` ASC) USING BTREE,
|
||||
INDEX `fk_org_department_updater`(`update_by` ASC) USING BTREE,
|
||||
CONSTRAINT `fk_org_department_company` FOREIGN KEY (`company_id`) REFERENCES `org_company` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_org_department_creator` FOREIGN KEY (`create_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_org_department_parent` FOREIGN KEY (`parent_id`) REFERENCES `org_department` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
CONSTRAINT `fk_org_department_updater` FOREIGN KEY (`update_by`) REFERENCES `sys_user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '系统模块-部门表'
|
||||
|
||||
-- ========================================
|
||||
-- 部门成员表
|
||||
-- ========================================
|
||||
DROP TABLE IF EXISTS `org_department_member`;
|
||||
CREATE TABLE `org_department_member` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`user_id` bigint UNSIGNED NOT NULL,
|
||||
`department_id` bigint UNSIGNED NOT NULL,
|
||||
`status` tinyint NOT NULL DEFAULT 1 COMMENT '状态: 0=禁用, 1=正常',
|
||||
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`create_by` bigint UNSIGNED NULL DEFAULT NULL,
|
||||
`update_by` bigint UNSIGNED NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE,
|
||||
UNIQUE INDEX `uk_user_department`(`user_id` ASC, `department_id` ASC) USING BTREE,
|
||||
INDEX `idx_department`(`department_id` ASC) USING BTREE,
|
||||
INDEX `idx_user`(`user_id` ASC) USING BTREE,
|
||||
CONSTRAINT `fk_dm_department` FOREIGN KEY (`department_id`) REFERENCES `org_department` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
|
||||
CONSTRAINT `fk_dm_user` FOREIGN KEY (`user_id`) REFERENCES `sys_user` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
|
||||
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci COMMENT = '部门成员表'
|
||||
Reference in New Issue
Block a user