DocumentionUmo Office ConvertDatabase

Database Overview

This document describes the database design used by the Umo Office Convert service. The service uses MySQL to store information related to document conversion tasks. You can also follow the same implementation approach and choose a different database.

Database Configuration

Database configuration is stored in environment variables and can be configured via the .env file. For details, see: Environment Variables - MySQL Database Configuration.

Table Schema

convert_tasks table

This table is used to store information about document conversion tasks.

ColumnTypeDescriptionConstraints
idVARCHAR(255)Task IDPRIMARY KEY
filenameVARCHAR(255)Original filename
mimeVARCHAR(255)File MIME type
sizeINTOriginal file size (bytes)
pathVARCHAR(255)Original file path
hashVARCHAR(255)File hash
converted_sizeINTConverted file size (bytes)
converted_pathVARCHAR(255)Converted file path
cover_pathVARCHAR(255)document cover path
summaryTEXTdocument summary
statusVARCHAR(255)Conversion status
converted_atTIMESTAMPConversion timeDEFAULT CURRENT_TIMESTAMP

Possible values of the status field include:

  • uploaded: file uploaded
  • converted: conversion completed
  • failed: conversion failed

Database Initialization

When the service starts, it will automatically check and create the required data tables. The initialization code is located in src/utils/mysql.mjs.

Data Flow

  1. When a conversion task is obtained through the API, the system will create a new conversion task record. If an already converted task is matched by file hash, the system will not create a new task and will directly retrieve the converted file from cache.
  2. After conversion completes, the converted file information and status will be updated.
  3. Users can query conversion task information and results by task ID.

Caching Mechanism

The system uses the file hash value as a cache mechanism. When a user uploads the same file, the system checks whether a conversion task with the same hash already exists in the database. If it exists and the conversion succeeded, the system returns the converted file directly to avoid repeated conversion.

Backup Recommendations

It is recommended to regularly back up the convert_tasks table data to prevent data loss. You can use the following command to back up:

mysqldump -u [username] -p [database] convert_tasks > convert_tasks_backup_$(date +%Y%m%d).sql