> For the complete documentation index, see [llms.txt](https://documentation.rcore.cz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.rcore.cz/paid-resources/rcore_housing/integrations/database.md).

# Database

`rcore_housing` supports three database resources and creates its own tables on first boot.

## 🔎 Auto Detection

```lua
Config.Database = AUTO_DETECT
```

Override with `Database.OX`, `Database.MYSQL_ASYNC`, or `Database.GHMATTI` only when detection is wrong.

## 🧩 Supported Resources

Resource: `oxmysql` - **recommended**.

`rcore_housing` runs every query through `oxmysql` when this bridge is selected. Recent versions are required for `EXPLAIN` support, which the resource uses to auto-create missing indexes.

```cfg
ensure oxmysql
ensure [housing]
```

Resource: `mysql-async`

The bridge wraps `mysql-async` calls in promises. The resource still auto-creates tables; index optimization is best-effort.

```cfg
ensure mysql-async
ensure [housing]
```

## 🗄️ Auto-Created Tables

On first boot, the resource creates and indexes these tables (idempotent - `CREATE TABLE IF NOT EXISTS`):

| Table                                     | Purpose                                                                 |
| ----------------------------------------- | ----------------------------------------------------------------------- |
| `rcore_housing_properties`                | Property definitions, owners, tenants, state, zones.                    |
| `rcore_housing_players`                   | Per-player housing state (last property, starter assignment).           |
| `rcore_housing_data_patches`              | Used for tracking any SQL patches for housing new features / bug fixes. |
| `rcore_housing_property_accessories`      | Per-property upgrades and metadata.                                     |
| `rcore_housing_furniture`                 | Furniture catalog (master list).                                        |
| `rcore_housing_furniture_variants`        | Color variants per furniture item.                                      |
| `rcore_housing_property_furniture`        | Furniture placed inside properties.                                     |
| `rcore_housing_property_furniture_stock`  | Furniture owned but unplaced.                                           |
| `rcore_housing_property_furniture_orders` | Pending furniture deliveries.                                           |
| `rcore_housing_billing`                   | Active rent / utilities bills.                                          |
| `rcore_housing_rent_ledger`               | Payment history.                                                        |
| `rcore_housing_keys`                      | Per-player access keys.                                                 |
| `rcore_housing_accesses`                  | Per-door access grants.                                                 |
| `rcore_housing_marketplace_listings`      | Marketplace listings.                                                   |
| `rcore_housing_marketplace_favorites`     | Player favourites.                                                      |
| `rcore_housing_business_permissions`      | Per-grade business permissions.                                         |
| `rcore_housing_interior_catalog`          | Custom SHELLs and IPLs from the Interior Creator.                       |
