Skip to main content
SQL modules are plain .sql files that are applied to the database when you run dbtool update. They can insert new records, update existing data, or delete rows — anything you can express in SQL. Common uses:
  • Adjusting mob drop tables (add, remove, or reweight drops)
  • Relocating dangerous mob spawn points
  • Inserting custom NPC records
  • Modifying item stats or availability
  • Changing quest or ability data stored in the database

How SQL modules work

When dbtool update runs, it applies any .sql files that are listed (directly or via their parent folder) in modules/init.txt. The files are executed in the order they are listed. SQL modules run against the live database, so they must be written to be idempotent — safe to apply more than once.
Always write SQL modules so they can be re-run without causing errors or corrupting data. Use INSERT IGNORE, ON DUPLICATE KEY UPDATE, or WHERE clauses that target specific rows rather than bulk operations without guards.

Creating a SQL module

1

Create your SQL file

Place the file in modules/custom/sql/ (or any subfolder of modules/).
modules/custom/sql/safe_outposts.sql
Use WHERE clauses that match the exact current position or values, so the update is a no-op if already applied.
2

Register it in init.txt

init.txt
3

Apply it by running dbtool update

In Docker:

Idempotency patterns

SQL modules may be applied every time dbtool update runs. Use these patterns to prevent duplicate inserts or errors on re-run.

Example: removing mob drops

The era accuracy modules in modules/toau/sql/ show a real pattern for removing items from the drop table:
modules/toau/sql/mob_droplist_removal.sql
DELETE statements are not idempotent in the strict sense — a second run is a no-op only because the row is already gone. They are safe to re-run as long as you do not need the data restored between runs.

Example: enabling a custom NPC

modules/custom/sql/lsb_mascot.sql

Common tables