Skip to content

Storage

DynaDev edited this page Aug 12, 2026 · 1 revision

Storage

TownyAlerts does not require a database.

The default backend is:

storage:
  type: memory

Supported storage types:

  • MEMORY
  • SQLite
  • MariaDB
  • MySQL

Storage is used for TownyAlerts history and persistent deduplication. It does not replace or modify Towny's own database/storage.

MEMORY

Configuration:

storage:
  type: memory

Properties:

  • Default option
  • No files created
  • No external database
  • Fast and simple
  • Deduplication lasts only for the current process

After a full server restart, memory-only deduplication state is lost.

SQLite

Configuration:

storage:
  type: sqlite

  sqlite:
    file: "townyalerts.db"

The database is stored inside the TownyAlerts plugin data folder.

Conceptually:

plugins/TownyAlerts/townyalerts.db

TownyAlerts rejects absolute paths and path traversal attempts for SQLite storage.

SQLite is a good choice for a single Minecraft server that wants persistence without running a separate database service.

MariaDB

Example:

storage:
  type: mariadb
  server-id: "towny-1"

  remote:
    host: "127.0.0.1"
    port: 3306
    database: "townyalerts"
    username: "townyalerts"
    password: ""
    password-env: "TOWNYALERTS_DB_PASSWORD"
    ssl: false
    connection-timeout-ms: 5000

MySQL

Use:

storage:
  type: mysql

The remote database settings use the same configuration structure.

Create the database first

TownyAlerts does not create:

  • Database server users
  • Databases
  • Grants/permissions

Create the database and database user through your hosting panel, Pterodactyl, MariaDB/MySQL administration tools, or another trusted management method.

TownyAlerts can create its own tables inside the configured database when allowed:

storage:
  schema:
    auto-create-tables: true

Password from an environment variable

Recommended for servers where environment variables can be configured:

storage:
  remote:
    password: ""
    password-env: "TOWNYALERTS_DB_PASSWORD"

The environment variable value has priority over the literal password field.

The password is not displayed by TownyAlerts status commands.

Server ID

storage:
  server-id: "default"

server-id separates records when multiple Minecraft servers use the same MariaDB/MySQL database.

Example:

storage:
  server-id: "towny-production"

Use a stable value and do not change it casually after production data has been written.

History retention

storage:
  history:
    enabled: true
    retention-days: 0

A value of 0 means indefinite retention when supported by the current implementation.

Failure isolation

Database operations are asynchronous and isolated from Towny event handling.

A database failure must not:

  • Cancel a Towny event
  • Prevent Towny taxes/upkeep
  • Crash New Day processing

Discord sending and database persistence are also isolated from each other.

Test storage

Run:

/townyalerts storage test

The command performs a safe connectivity/query test and does not create Towny economy activity.

Clone this wiki locally