# Updates

Application versions follow semver and are stored in:

- `VERSION`
- `release/version.json`
- `system_versions` table

## Admin update page

Open **System → System update** (`/admin/system/update`).

Only administrators with `updates.execute` can apply updates.

## Safe update process

1. Current and target versions are recorded.
2. A database backup is created. If backups are required (`UPDATE_REQUIRE_BACKUP=true`) and backup fails, the update stops.
3. The application enters maintenance mode.
4. Optional ZIP package is validated (`release/version.json`) and extracted.
5. `.env`, `storage/app`, uploads, and business data are **not** overwritten.
6. `php artisan migrate --force` runs. **`migrate:fresh` is never used.**
7. Caches are cleared, `VERSION` is updated, maintenance mode is disabled.
8. The result is stored in `system_updates`.

## Package layout

```
release/version.json
VERSION
database/migrations/   # new files only; never edit released migrations
CHANGELOG.md
```

## Notes

- Do not modify released migrations.
- New schema changes must be new migration files.
- Composer is not required on the server if the package already contains `vendor/`.
