DND Docs

Resourcesdnd_economyInstallation

Database Setup

Last updated on

server/migrator.lua runs on every resource start and brings the schema up to date on its own:

  • Fresh install (no dnd_eco_* tables yet) → runs sql/install.sql and marks every migration as already applied.
  • Existing schema → resumes from the last applied migration, tracked in dnd_eco_schema_versions.
  • Legacy de_* prefix (pre-rename) → walks migrations forward from the rename point.
  • Hand-migrated schema (tables look current but no version rows exist yet) → creates the version table, then checks each migration's effect against the live schema and marks it applied without re-running it.

Just start the resource — nothing to run manually. Migration failure aborts boot on purpose (booting with a half-migrated schema is worse than not booting).

Manual

If you'd rather import it yourself: run sql/install.sql once against your database. It creates every table this resource needs:

TablePurpose
dnd_eco_itemsMaster commodity list (base price, floor/ceiling/sensitivity/decay)
dnd_eco_agenciesAgency config mirror (label, job, collection, commission, Buy price adjustment, webhook)
dnd_eco_agency_stockPer-agency-item runtime state (current price, target stock, price holds)
dnd_eco_transactionsSell + Buy history (direction column), buyer/seller/handler identifiers and names, order_id (groups a cart's line items into one Dashboard entry) and payment_method (cash/bank)
dnd_eco_player_cooldownsPer-player, per-item Sell cooldown
dnd_eco_price_snapshotsPrice history for trend sparklines
dnd_eco_schema_versionsMigration tracking

Config vs database

Most agency/item fields are synced from config.lua on every boot (server/config_sync.lua) — label, collection, job, commission, etc. always track your config. A few fields are dashboard-editable at runtime and deliberately excluded from that sync so they survive a restart:

  • dnd_eco_agencies.webhook_url
  • dnd_eco_agencies.buy_price_adjustment
  • dnd_eco_items.overridden economic properties (base price, floor, ceiling, sensitivity, decay) — only once a government-access user has edited them from the Dashboard.

v2.0.0 schema updates

The following migrations were added in v2.0.0 to support agency budgets, transaction tax, and price spreads:

MigrationAddsPurpose
0017_price_spreadagencies.spread_pct, instansi_discount, gang_markupPer-agency price adjustment controls
0018_agency_budgetagencies.budget_enforced, quota_limit, quota_cycle_hours, quota_spent, cycle_start_tsAgency spending limits and cycle tracking
0019_stock_target_overriddenagency_stock.target_overriddenTrack which stock targets have been edited from the default
0020_transaction_taxtransactions.tax_paidRecord how much tax was collected on each transaction

These run automatically on boot. No manual SQL needed.

Dashboard-edited fields (survive restart)

The following fields are intentionally excluded from the config sync so they survive a restart and reflect staff/manager edits made from the Dashboard:

  • dnd_eco_agencies.webhook_url
  • dnd_eco_agencies.buy_price_adjustment (renamed to instansi_discount/gang_markup in v2.0.0)
  • dnd_eco_agencies.spread_pct, instansi_discount, gang_markup
  • dnd_eco_agencies.quota_limit, quota_cycle_hours (per-agency overrides on top of config defaults)
  • dnd_eco_items.overridden economic properties (base price, floor, ceiling, sensitivity, decay) — only once a government-access user has edited them from the Dashboard.

All other fields are re-synced from config.lua on every boot, so config changes always take effect immediately without any manual DB edits.

On this page