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.
| Column | Type | Description | Constraints |
|---|---|---|---|
| id | VARCHAR(255) | Task ID | PRIMARY KEY |
| filename | VARCHAR(255) | Original filename | |
| mime | VARCHAR(255) | File MIME type | |
| size | INT | Original file size (bytes) | |
| path | VARCHAR(255) | Original file path | |
| hash | VARCHAR(255) | File hash | |
| converted_size | INT | Converted file size (bytes) | |
| converted_path | VARCHAR(255) | Converted file path | |
| cover_path | VARCHAR(255) | document cover path | |
| summary | TEXT | document summary | |
| status | VARCHAR(255) | Conversion status | |
| converted_at | TIMESTAMP | Conversion time | DEFAULT CURRENT_TIMESTAMP |
Possible values of the status field include:
uploaded: file uploadedconverted: conversion completedfailed: 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
- 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. - After conversion completes, the converted file information and status will be updated.
- 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