> For the complete documentation index, see [llms.txt](https://hollow-peak.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://hollow-peak.gitbook.io/docs/technical-reference/database-and-migrations.md).

# Database & Migrations

The schema, migrations and connection settings.

## The schema

Around **80 tables**, created entirely by migrations. There is no SQL dump, and you will never be asked to import one.

```bash
php artisan migrate
```

Hollow Peak's installer runs this for you.

## Seeders

| Seeder           | Contains                             | Run by                |
| ---------------- | ------------------------------------ | --------------------- |
| `SystemSeeder`   | Roles, permissions, default settings | The installer, always |
| `DemoSeeder`     | Sample content                       | Only with `--demo`    |
| `DatabaseSeeder` | Calls `SystemSeeder`                 | `php artisan db:seed` |

{% hint style="info" %}
**No seeder creates a user account.** The first administrator is created by `hollowpeak:install` from answers given at the prompt.

A seeder that created one would have to invent a password, and every copy of the product would ship with the same administrator credentials.
{% endhint %}

Both seeders are safe to re-run — every write is a `firstOrCreate` or `updateOrCreate`, so an update that adds a permission can simply run `SystemSeeder` again.

## The database connection screen

**Site Management → Database**

Change the database connection without editing `.env` over SSH.

{% hint style="warning" %}
**Owner role only.** Not a permission — role membership. These are the credentials to everything the platform holds, and a permission would sit on the roles screen waiting to be granted.
{% endhint %}

**Saving tries the details before writing them.** If nothing answers, nothing is saved — otherwise a mistyped host would point the site at a database that is not there, taking this screen down with it.

**Test Connection** checks without saving.

## InnoDB

```ini
DB_ENGINE="InnoDB ROW_FORMAT=DYNAMIC"
```

{% hint style="danger" %}
Do not change this. The order and payment flows depend on transactions and foreign keys. MyISAM accepts both silently and honours neither, which means a failed payment can leave a half-written order with nothing to indicate it.
{% endhint %}

## Backups

```bash
mysqldump -u user -p database_name > backup-$(date +%F).sql
```

The database is not enough on its own. Also back up `storage/app` (uploads and paid files) and `.env` (in particular `APP_KEY`).

### Restoring

```bash
mysql -u user -p database_name < backup.sql
```

Then restore `storage/app` and confirm `APP_KEY` matches the backup. **A different `APP_KEY` makes every encrypted setting unreadable.**

## Storage, cache, sessions and queues

| Concern       | Default               | Notes                                                                 |
| ------------- | --------------------- | --------------------------------------------------------------------- |
| Uploads       | `storage/app/public`  | Public via the storage symlink                                        |
| Private files | `storage/app/private` | Paid downloads, payment proofs, chat attachments. Never web-reachable |
| Cache         | Database              | No Redis needed                                                       |
| Sessions      | Database              | Survives a restart                                                    |
| Queues        | `sync`                | Runs during the request; no worker needed                             |

### Clearing caches

```bash
php artisan optimize:clear   # everything
php artisan config:clear     # after editing .env
php artisan view:clear       # after editing templates
```

### The scheduler

Closes stale attendance sessions and performs housekeeping.

```
* * * * * cd /path/to/hollowpeak && php artisan schedule:run >> /dev/null 2>&1
```

Without it the platform works, but attendance sessions from closed laptops stay open.

## Logs

`storage/logs/laravel-*.log`, rotated daily, kept for `LOG_DAILY_DAYS`.

Logs can contain customer email addresses. Keep retention short and do not expose them.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hollow-peak.gitbook.io/docs/technical-reference/database-and-migrations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
