/*
 Navicat Premium Data Transfer

 Source Server         : mysql-210
 Source Server Type    : MySQL
 Source Server Version : 50732
 Source Host           : 192.168.0.149:3306
 Source Schema         : tnb_oss_rdb

 Target Server Type    : MySQL
 Target Server Version : 50732
 File Encoding         : 65001

 Date: 15/01/2026 15:44:46
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for data_block
-- ----------------------------
DROP TABLE IF EXISTS `data_block`;
CREATE TABLE `data_block` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `deleted` bit(1) NOT NULL DEFAULT b'0',
  `create_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `update_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `content_id` varchar(255) NOT NULL,
  `block_id` varchar(255) NOT NULL,
  `host` varchar(255) NOT NULL,
  `absolute_path` varchar(255) NOT NULL COMMENT '本地文件绝对路径',
  `size` bigint(20) NOT NULL,
  `replica` int(11) DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `content_id` (`content_id`) USING BTREE,
  KEY `absolute_path` (`absolute_path`),
  KEY `size` (`size`),
  KEY `deleted` (`deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='对象数据块';

-- ----------------------------
-- Table structure for file_meta
-- ----------------------------
DROP TABLE IF EXISTS `file_meta`;
CREATE TABLE `file_meta` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `deleted` bit(1) NOT NULL DEFAULT b'0',
  `create_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `update_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `object_name` varchar(255) NOT NULL,
  `object_id` varchar(255) NOT NULL,
  `pid` varchar(255) NOT NULL,
  `content_id` varchar(255) NOT NULL,
  `sha256sum` varchar(255) NOT NULL COMMENT '文件的 sha256sum 值',
  `filename` varchar(255) NOT NULL,
  `size` bigint(20) NOT NULL,
  `file_type` int(11) NOT NULL,
  `content_type` varchar(255) NOT NULL COMMENT 'http content-type',
  `scope` int(11) NOT NULL,
  `upload_by` varchar(255) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UK_rfuvf3osnlaakifjdao0a8e2x` (`object_name`) USING BTREE,
  UNIQUE KEY `object_id` (`object_id`) USING BTREE,
  KEY `sha256sum` (`sha256sum`) USING BTREE,
  KEY `file_type` (`file_type`),
  KEY `pid` (`pid`),
  KEY `filename` (`filename`),
  KEY `acl` (`scope`),
  KEY `content_id` (`content_id`),
  KEY `upload_by` (`upload_by`),
  KEY `deleted` (`deleted`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='对象元数据';

-- ----------------------------
-- Table structure for file_multipart
-- ----------------------------
DROP TABLE IF EXISTS `file_multipart`;
CREATE TABLE `file_multipart` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `deleted` bit(1) NOT NULL DEFAULT b'0',
  `create_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `update_time` datetime(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  `content_id` varchar(255) NOT NULL,
  `absolute_path` varchar(255) NOT NULL,
  `sha256sum` varchar(255) NOT NULL COMMENT '文件的 sha256sum 值',
  `total_size` bigint(20) NOT NULL,
  `chunk_size` int(11) NOT NULL,
  `total_chunks` int(11) NOT NULL,
  `uploaded` bit(1) NOT NULL,
  `upload_by` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `sha256sum_uploadby` (`sha256sum`,`upload_by`) USING BTREE,
  UNIQUE KEY `content_id` (`content_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分片文件';

-- ----------------------------
-- Table structure for file_part
-- ----------------------------
DROP TABLE IF EXISTS `file_part`;
CREATE TABLE `file_part` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `content_id` varchar(255) NOT NULL,
  `chunk_number` int(11) NOT NULL,
  `current_chunk_size` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `sha256sum` (`content_id`,`chunk_number`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='分片文件';

SET FOREIGN_KEY_CHECKS = 1;
