CREATE TABLE files
(
    id            INTEGER PRIMARY KEY GENERATED ALWAYS AS IDENTITY,
    file_name     TEXT      NOT NULL,
    file_path     TEXT      NOT NULL,
    original_name TEXT      NOT NULL,
    folder_name   TEXT      NOT NULL,
    mime_type     TEXT      NOT NULL,
    file_size     BIGINT    NOT NULL,
    created_at    TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    updated_at    TIMESTAMPTZ
);

CREATE TRIGGER update_files_updated_at
    BEFORE UPDATE
    ON files
    FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();

COMMENT ON COLUMN files.id IS '主键ID';
COMMENT ON COLUMN files.file_name IS '文件名 xxx.jpg';
COMMENT ON COLUMN files.file_path IS '文件路径 带path /xxx/xxx.jpg';
COMMENT ON COLUMN files.original_name IS '原始文件名';
COMMENT ON COLUMN files.folder_name IS '文件夹名称';
COMMENT ON COLUMN files.mime_type IS 'mime_type';
COMMENT ON COLUMN files.file_size IS '文件大小';
COMMENT ON COLUMN files.created_at IS '上传时间';
COMMENT ON COLUMN files.updated_at IS '修改时间';
