# Database

RageMode stores information about players, games and many other sensitive data.

{% hint style="info" %}
`/rm convertdatabase` command can switch from existing database to a different one, but data corruption and lose may happen. Make sure to create backup before doing this.
{% endhint %}

{% hint style="warning" %}
We are not responsible for any data loss or corruption, please perform a backup first if you make any database changes.
{% endhint %}

#### Outdated data purge

It is possible to remove old, non-updated data after a specified interval. This is specified in days. Any higher number than `0` will start purging old data from database. If the value is 0, no data will be removed.

```yml
storage:
  cleanup-days: 0
```

#### Table names configuration

You can as well configure each table names, these are only used for SQL-based databases where database structures can be created.

{% hint style="warning" %}
Modifying any table name from configuration, the plugin won't perform rename process of the existing&#x20;

tables. Make sure to create a backup before performing this. Data is never transferred to new tables.
{% endhint %}

```yml
table-names:
  player-missions: ragemode_player_missions
  game-history: ragemode_game_history
  stats-players: ragemode_stats_players
  players: ragemode_players
  player-skills: ragemode_player_skills
  skill-levels: ragemode_player_skill_levels
```

## YAML (default)

YAML[^1] database is a low-cost local configuration for storing minimal data for small servers.

```yml
storage:
  type: yaml
```

## MySQL

MySQL[^2] is recommended for production servers as it provides better performance and reliability, while also enabling Cross-Server synchronisation, allowing data to be shared across multiple servers.

```yml
storage:
  type: mysql
  mysql:
    host: localhost
    port: 3306
    database: db
    username: username
    password: passw
    properties:
    - maxReconnects=3
    - autoReconnect=true
    - sslMode=DISABLED
```

* `host`
  * The IP address of your database server. If the database is on the same machine as your server, leave it as `localhost` or `127.0.0.1`. If using a remote host, enter that IP here.
* `port`
  * The network port MySQL is listening on. The default is `3306`
* `database`
  * The specific name of your database, make sure to create this database in you MySQL server
* `username`
  * The username required to authenticate with your MySQL server
* `password`
  * The password associated with the username above for authentication

## SQLite

SQLite[^3] provides local serverless database engine used for single servers.

```yml
storage:
  type: sqlite
```

You're able to change sql file name, <mark style="color:$danger;">**but your data won't be transferred afterwards.**</mark>

```yml
sql:
  file-name: rm.sqlite.db
```

#### Database properties

SQL-based databases can have different types of properties which gives extra accessibility. For the full list of available properties for MySQL visit [dev.mysql.com](https://dev.mysql.com/doc/connector-j/en/connector-j-reference-configuration-properties.html), for SQLite [sqlite.org](https://sqlite.org/pragma.html)

```yml
properties:
- maxReconnects=3
- autoReconnect=true
- sslMode=DISABLED
```

[^1]: <https://en.wikipedia.org/wiki/YAML>

[^2]: <http://en.wikipedia.org/wiki/MySQL>

[^3]: <https://en.wikipedia.org/wiki/SQLite>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mdswork.gitbook.io/ragemode-docs/database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
