Skip to main content

πŸ—„οΈ Database Management

Hello there! Welcome to the Database management guide for Open Ticket. Here we will try to help you with managing, migrating and fixing corrupt tickets.

Managing your Open Ticket database allows you to read, modify, transfer, and back up your data and tickets. By default, Open Ticket stores all data in JSON files, but database plugins can be used for optimized performance.

DB Management

Modifying, fixing & transfering databases


πŸ“‚ Database Structure​

By default, Open Ticket stores all data inside the ./database/ folder, divided into five JSON files:

  • global.json – Stores global variables, including the last Open Ticket version used, IDs of auto-updating panels, and other general data.
  • tickets.json – Stores all ticket-related data, including creation time, participant IDs, ticket status and plugin data.
  • users.json – Currently not used but reserved for plugins to store custom user data.
  • stats.json – Holds global, user, and ticket statistics (e.g., total tickets created).
  • options.json – Keeps a backup of all ticket options used from the options.json config. If an option is missing from the config, it retrieves it from here.

✏️ Manually Editing The Database​

Since Open Ticket stores data in raw JSON files, you can open and edit them using any text editor (VS Code, Notepad++, etc).

πŸ“– JSON File Structure​

All data in Open Ticket is structured as an array of objects using a "category", "key", and "value":

[   {"category": "openticket:variable-type", "key": "user/message/ticket id", "value":null}   ]
  • category – Defines what type of variable is stored (e.g. openticket:ticket).
  • key – The unique identifier, such as a user ID, message ID, or ticket ID.
  • value – The stored data (could be a string, number, boolean, object, array or null).
warning
  • Never modify the database structure (keep the category, key, and value format).
  • Back up your files before making any manual changes.
  • Stop the bot before editing the database to prevent corruption.

πŸ”„ Transferring Your Database​

All database-related plugins will contain a built-in feature to migrate the JSON database to its own system.
If you want to transfer your database to a new Open Ticket version, see the guide below:

⬆️ Updating Open Ticket​

Follow these steps when you want to update Open Ticket:

  1. Copy the ./database/, ./config/ & ./plugins/ folders to another separate location.
  2. Update the bot by downloading a new version from Github.
  3. Install all required npm dependencies and make sure the bot is able to start.
  4. Paste back the original ./database/, ./config/ & ./plugins/ folders in the new bot.

πŸ› οΈ Using Database Plugins​

Open Ticket supports database plugins to replace JSON storage with SQLite, Redis, MongoDB or other options. (some plugins do not exist yet)

πŸ“Œ Why Use Database Plugins?*​

βœ… Improved Performance – Faster queries compared to reading JSON files.
βœ… Better Scalability – Required for large servers with thousands of tickets.
βœ… Reduced Corruption Risk – Unlike JSON, databases handle concurrent writes properly.


πŸ’‘ Best Practices​

  • πŸ”„ Make Regular Backups – Copy the ./database/ folder or export your database plugin data.
  • ⚑ Use a Database Plugin for Large Servers – JSON storage is fine for small servers, but SQLite is better for large-scale use.
  • 🚧 Avoid Manual Editing If Possible – Use plugins or Open Ticket’s built-in commands to modify data safely.

πŸ† Summary​

Now you know:
βœ… Which databases exist in Open Ticket. βœ… How to properly edit the database.
βœ… How to optimize the database for large servers.

⭐ awesome ⭐

Don't forget to give Open Ticket a star on GitHub to help us grow!

Next Steps​

Learn More​