> For the complete documentation index, see [llms.txt](https://tyrix.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tyrix.gitbook.io/docs/script-resources/tyrix-business/database.md).

# Database

All four tables auto-create on resource start. No manual `install.sql` import needed - running `install/install.sql` yourself is optional and only useful if you want to pre-provision the schema or hand it to a DBA as reference.

## Tables

| Table                     | Purpose                                                         |
| ------------------------- | --------------------------------------------------------------- |
| `tyrix_businesses`        | Per-business JSON columns for every feature type.               |
| `tyrix_crafting_stations` | Crafting stations with a `station_data` JSON blob.              |
| `tyrix_recipes`           | Recipes with a `recipe_data` JSON blob.                         |
| `tyrix_business_activity` | Audit log of every feature create / update / delete / relocate. |

Full DDL lives in `install/install.sql`.

## Auto-migration

The resource creates its tables with `CREATE TABLE IF NOT EXISTS` and then pins their charset to `utf8mb4` / `utf8mb4_general_ci` via an idempotent `ALTER TABLE`. Both are safe to run on every restart.

## Society tables (framework side)

When a new business is created through the Business Manager, tyrix\_business seeds the framework's society tables (ESX side: `addon_account`, `addon_account_data`, `addon_inventory`, `datastore`, `datastore_data`) so the business's money account and boss inventory exist immediately. Existing society rows are left alone.
