/*
 Yudao Database Transfer Tool

 Source Server Type    : MySQL

 Target Server Type    : DM8

 Date: 2025-08-29 10:32:27
*/


-- ----------------------------
-- Table structure for infra_doc_file
-- ----------------------------
CREATE TABLE infra_doc_file (
    id bigint NOT NULL PRIMARY KEY,
    title varchar(255)  NOT NULL,
    file_id bigint DEFAULT NULL NULL,
    file_type varchar(10)  NOT NULL,
    space_type smallint DEFAULT '1' NOT NULL,
    description varchar(500) DEFAULT NULL NULL,
    latest_version_id bigint DEFAULT NULL NULL,
    owner_user_id bigint  NOT NULL,
    status smallint DEFAULT '1' NOT NULL,
    creator varchar(64) DEFAULT '' NULL,
    create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updater varchar(64) DEFAULT '' NULL,
    update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
    deleted bit DEFAULT '0' NOT NULL,
    tenant_id bigint DEFAULT '0' NOT NULL
);

CREATE INDEX idx_infra_doc_file_01 ON infra_doc_file (owner_user_id);
CREATE INDEX idx_infra_doc_file_02 ON infra_doc_file (space_type);
CREATE INDEX idx_infra_doc_file_03 ON infra_doc_file (file_type);

COMMENT ON COLUMN infra_doc_file.id IS '文档编号';
COMMENT ON COLUMN infra_doc_file.title IS '文档标题';
COMMENT ON COLUMN infra_doc_file.file_id IS '文件编号';
COMMENT ON COLUMN infra_doc_file.file_type IS '文件类型(docx/xlsx/pptx/pdf)';
COMMENT ON COLUMN infra_doc_file.space_type IS '空间类型(1-个人空间 2-团队空间)';
COMMENT ON COLUMN infra_doc_file.description IS '文档描述';
COMMENT ON COLUMN infra_doc_file.latest_version_id IS '最新版本编号';
COMMENT ON COLUMN infra_doc_file.owner_user_id IS '所有者用户编号';
COMMENT ON COLUMN infra_doc_file.status IS '状态(0-禁用 1-启用)';
COMMENT ON COLUMN infra_doc_file.creator IS '创建者';
COMMENT ON COLUMN infra_doc_file.create_time IS '创建时间';
COMMENT ON COLUMN infra_doc_file.updater IS '更新者';
COMMENT ON COLUMN infra_doc_file.update_time IS '更新时间';
COMMENT ON COLUMN infra_doc_file.deleted IS '是否删除';
COMMENT ON COLUMN infra_doc_file.tenant_id IS '租户编号';
COMMENT ON TABLE infra_doc_file IS '在线文档表';

-- ----------------------------
-- Table structure for infra_doc_file_version
-- ----------------------------
CREATE TABLE infra_doc_file_version (
    id bigint NOT NULL PRIMARY KEY,
    doc_file_id bigint  NOT NULL,
    version_no varchar(50)  NOT NULL,
    file_id bigint  NOT NULL,
    change_description varchar(500) DEFAULT NULL NULL,
    creator varchar(64) DEFAULT '' NULL,
    create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updater varchar(64) DEFAULT '' NULL,
    update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
    deleted bit DEFAULT '0' NOT NULL,
    tenant_id bigint DEFAULT '0' NOT NULL
);

CREATE INDEX idx_infra_doc_file_version_01 ON infra_doc_file_version (doc_file_id);
CREATE INDEX idx_infra_doc_file_version_02 ON infra_doc_file_version (version_no);

COMMENT ON COLUMN infra_doc_file_version.id IS '版本编号';
COMMENT ON COLUMN infra_doc_file_version.doc_file_id IS '文档编号';
COMMENT ON COLUMN infra_doc_file_version.version_no IS '版本号';
COMMENT ON COLUMN infra_doc_file_version.file_id IS '文件编号';
COMMENT ON COLUMN infra_doc_file_version.change_description IS '变更说明';
COMMENT ON COLUMN infra_doc_file_version.creator IS '创建者';
COMMENT ON COLUMN infra_doc_file_version.create_time IS '创建时间';
COMMENT ON COLUMN infra_doc_file_version.updater IS '更新者';
COMMENT ON COLUMN infra_doc_file_version.update_time IS '更新时间';
COMMENT ON COLUMN infra_doc_file_version.deleted IS '是否删除';
COMMENT ON COLUMN infra_doc_file_version.tenant_id IS '租户编号';
COMMENT ON TABLE infra_doc_file_version IS '文档版本表';

-- ----------------------------
-- Table structure for infra_doc_file_permission
-- ----------------------------
CREATE TABLE infra_doc_file_permission (
    id bigint NOT NULL PRIMARY KEY,
    doc_file_id bigint  NOT NULL,
    role_id bigint NOT NULL,
    permission_type smallint DEFAULT '1' NOT NULL,
    expire_time datetime DEFAULT NULL NULL,
    creator varchar(64) DEFAULT '' NULL,
    create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
    updater varchar(64) DEFAULT '' NULL,
    update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
    deleted bit DEFAULT '0' NOT NULL,
    tenant_id bigint DEFAULT '0' NOT NULL
);

CREATE INDEX idx_infra_doc_file_permission_01 ON infra_doc_file_permission (role_id);

COMMENT ON COLUMN infra_doc_file_permission.id IS '权限编号';
COMMENT ON COLUMN infra_doc_file_permission.doc_file_id IS '文档编号';
COMMENT ON COLUMN infra_doc_file_permission.role_id IS '角色编号';
COMMENT ON COLUMN infra_doc_file_permission.permission_type IS '权限类型(1-只读 2-编辑 3-管理)';
COMMENT ON COLUMN infra_doc_file_permission.expire_time IS '过期时间';
COMMENT ON COLUMN infra_doc_file_permission.creator IS '创建者';
COMMENT ON COLUMN infra_doc_file_permission.create_time IS '创建时间';
COMMENT ON COLUMN infra_doc_file_permission.updater IS '更新者';
COMMENT ON COLUMN infra_doc_file_permission.update_time IS '更新时间';
COMMENT ON COLUMN infra_doc_file_permission.deleted IS '是否删除';
COMMENT ON COLUMN infra_doc_file_permission.tenant_id IS '租户编号';
COMMENT ON TABLE infra_doc_file_permission IS '文档权限表';

-- ----------------------------
-- Table structure for infra_doc_edit_history
-- ----------------------------
CREATE TABLE infra_doc_edit_history (
    id bigint NOT NULL PRIMARY KEY,
    doc_file_id bigint  NOT NULL,
    user_id bigint  NOT NULL,
    user_name varchar(100)  NOT NULL,
    edit_type smallint DEFAULT '1' NOT NULL,
    description varchar(500) DEFAULT NULL NULL,
    create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
    tenant_id bigint DEFAULT '0' NOT NULL
);

CREATE INDEX idx_infra_doc_edit_history_01 ON infra_doc_edit_history (doc_file_id);
CREATE INDEX idx_infra_doc_edit_history_02 ON infra_doc_edit_history (user_id);

COMMENT ON COLUMN infra_doc_edit_history.id IS '历史编号';
COMMENT ON COLUMN infra_doc_edit_history.doc_file_id IS '文档编号';
COMMENT ON COLUMN infra_doc_edit_history.user_id IS '编辑用户编号';
COMMENT ON COLUMN infra_doc_edit_history.user_name IS '编辑用户名称';
COMMENT ON COLUMN infra_doc_edit_history.edit_type IS '编辑类型(1-创建 2-编辑 3-删除 4-重命名)';
COMMENT ON COLUMN infra_doc_edit_history.description IS '操作描述';
COMMENT ON COLUMN infra_doc_edit_history.create_time IS '创建时间';
COMMENT ON COLUMN infra_doc_edit_history.tenant_id IS '租户编号';
COMMENT ON TABLE infra_doc_edit_history IS '文档编辑历史表';
