# database

The database table is created automatically when the resource starts. No manual SQL setup is required.

✅ **Auto-creation:** On startup, the server script runs a `CREATE TABLE IF NOT EXISTS` query via oxmysql. The table will appear in your database on first resource start.

## ESX Schema

When running ESX, the table uses the player's `identifier` column.

```sql
CREATE TABLE IF NOT EXISTS `boombox_songs` ( `identifier` varchar(64) NOT NULL, `label` varchar(30) NOT NULL, `link` longtext NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

| Column       | Type        | Description                                          |
| ------------ | ----------- | ---------------------------------------------------- |
| `identifier` | varchar(64) | ESX player identifier (e.g. `steam:1100001xxxxxxxx`) |
| `label`      | varchar(30) | Player-defined name for the song (max 30 characters) |
| `link`       | longtext    | The YouTube URL for the saved track                  |

## QBCore Schema

When running QBCore, the table uses the player's `citizenid` column.

```sql
CREATE TABLE IF NOT EXISTS `boombox_songs` ( `citizenid` varchar(64) NOT NULL, `label` varchar(30) NOT NULL, `link` longtext NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

| Column      | Type        | Description                                          |
| ----------- | ----------- | ---------------------------------------------------- |
| `citizenid` | varchar(64) | QBCore citizen ID                                    |
| `label`     | varchar(30) | Player-defined name for the song (max 30 characters) |
| `link`      | longtext    | The YouTube URL for the saved track                  |

## Useful Queries

Run these manually in phpMyAdmin or your preferred DB tool if needed.

View all saved songs:

```sql
SELECT * FROM boombox_songs;
```

Delete a specific player's songs (ESX):

```sql
DELETE FROM boombox_songs WHERE identifier = 'steam:1100001xxxxxxxx';
```

Delete a specific player's songs (QBCore):

```sql
DELETE FROM boombox_songs WHERE citizenid = 'ABC12345';
```

Wipe all saved songs:

```sql
TRUNCATE TABLE boombox_songs;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mohssins.gitbook.io/mohscriptsdocs/moh-boombox/database.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
