# Database

Koja HUD creates no tables of its own.
It adds one column to your existing owned-vehicles table, to remember how much nitro each car has left.
Player settings are not stored in the database at all — they live in each player's game client.

## The `nitro` column

When `oxmysql` connects, the server runs:

```sql
ALTER TABLE `owned_vehicles` ADD COLUMN IF NOT EXISTS nitro INT DEFAULT 0;
```

with the table name taken from `KOJA.Nitro.Tables.GaragesTable`.
It is safe to run on every start: an existing column is left alone.

| Column | Type | Meaning |
| --- | --- | --- |
| `nitro` | `INT`, default `0` | Nitro left, 0–100. `0` means none installed |

If your database user may not alter tables, add the column yourself with the statement above — on QBCore and QBox the table is `player_vehicles`.

:::hint{type="warning" title="MySQL instead of MariaDB"}
`ADD COLUMN IF NOT EXISTS` is MariaDB syntax — the database most FiveM servers run.
MySQL does not accept it, so on MySQL the start-up statement fails: add the column by hand once, without `IF NOT EXISTS`.
:::

## How it is read and written

| When | What happens |
| --- | --- |
| A player takes the driver's seat | `SELECT plate, nitro` for that plate **and** the player's identifier in `OwnerColumn`. No row — not the owner — means no nitro |
| Nitro is installed | The same ownership check, then `nitro = 100` |
| A boost ends, or the driver gets out | `UPDATE … SET nitro = ? WHERE plate = ?`, only if the value went down |

Plates are matched both as stored and with surrounding spaces trimmed, because GTA pads plate text to eight characters.

## Resetting nitro

```sql
-- One vehicle
UPDATE owned_vehicles SET nitro = 0 WHERE plate = 'ABC 123';

-- Everyone
UPDATE owned_vehicles SET nitro = 0;
```

## Removing it

If you stop using nitro, set `KOJA.Nitro.Enabled = false` — the server side then does nothing, including the `ALTER TABLE`.
The column can stay; drop it only if nothing else reads it:

```sql
ALTER TABLE owned_vehicles DROP COLUMN nitro;
```
