-- 文件上传记录表
CREATE TABLE FileUploads (
    Id BIGINT AUTO_INCREMENT PRIMARY KEY,
    UserId BIGINT NOT NULL,                       -- 用户ID
    FileName VARCHAR(255) NOT NULL,               -- 原始文件名
    FileKey VARCHAR(500) NOT NULL,                -- 七牛云存储key
    FileSize BIGINT NOT NULL,                     -- 文件大小
    ContentType VARCHAR(100) NOT NULL,            -- 内容类型
    Hash VARCHAR(100) NOT NULL,                   -- 文件哈希值
    QiniuUrl VARCHAR(1000) NOT NULL,              -- 七牛云访问URL
    UploadTime DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    Status VARCHAR(20) NOT NULL DEFAULT 'active',
    CreatedAt DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- 创建索引
CREATE INDEX IX_FileUploads_UserId ON FileUploads(UserId);
CREATE INDEX IX_FileUploads_FileKey ON FileUploads(FileKey);
CREATE INDEX IX_FileUploads_UploadTime ON FileUploads(UploadTime);