# Limit journey versions to 5 (soft delete)

## Goal
Cap each journey's version history at **5**. On save, keep the 5 newest versions and soft-delete the rest (recoverable, not physically removed).

## Where
One place: `CustomJourneyVersion::record()` — the single funnel all save paths (`createJourney`, `silentSaveJourney`, `saveOtherJourney`) already flow through. Blasts return early before this code and are unaffected.

## Changes

### 1. Model — `app/Models/CustomJourneyVersion.php`
- Add Laravel's `SoftDeletes` trait. This makes every existing history query (`where('custom_journey_id', …)`, `find()`) exclude pruned rows automatically — so the version-history modal and restore endpoint show only the 5 live versions with **no changes to `JourneyController`**.
- Add `const MAX_VERSIONS = 5;`.
- Prune after the new snapshot is created:

```php
$version = static::create([...]);

$keep = static::where('custom_journey_id', $journey->id)
    ->orderByDesc('id')->limit(self::MAX_VERSIONS)->pluck('id');
static::where('custom_journey_id', $journey->id)
    ->whereNotIn('id', $keep)->delete();   // soft delete via trait

return $version;
```

Ordered by `id` (monotonic autoincrement), not `created_at` — `saveOtherJourney` can insert several rows with the same timestamp in one request, so `created_at` could tie.

### 2. Migration
`$table->softDeletes();` on `custom_journey_versions` (nullable `deleted_at`). No data backfill — existing rows stay active.

## Scope
Backend only. No frontend, no asset rebuild.

## Verification
Save the same journey 6 times → history query returns 5 rows, 1 row has non-null `deleted_at`. One assertion-based check.

## Note
Soft delete keeps rows in the DB, so storage still grows — it buys recoverability, not space. If capping DB size is the goal, switch to hard delete (`forceDelete()` / drop the trait).
