MigrationStore
The persistence of the tracking collection — the bookkeeping half of the migration engine.
One collection per database (default migrations) holds two families of
MigrationAction rows, told apart by their additionalType
(MigrationKind): the versioned migrations applied by the migrate
command (MigrationKind::MIGRATE), and the doctor --apply audit
entries (MigrationKind::DOCTOR). Only the former drive the pending
computation — the latter are an append-only audit trail.
Tags
Table of Contents
Properties
- $collection : string
- $database : Database
Methods
- __construct() : mixed
- append() : void
- Appends a `doctor --apply` audit row — a {@see MigrationKind::DOCTOR} event with a server-generated key, never replayed.
- applied() : array<string, MigrationAction>
- Returns the versions of the migrations already applied on this database — the {@see MigrationKind::MIGRATE} rows keyed by version, used to compute what is pending. An absent collection means "nothing applied yet" (empty map), not an error.
- ensureCollection() : void
- Creates the tracking collection if it does not exist yet — called before the first write of a run.
- remove() : void
- Removes a versioned migration row by version — used by the rollback (`--down`, after running `down()`) and the rescue (`--forget`).
- save() : void
- Inserts or updates a versioned migration row (`UPSERT` on `_key`) — used to record a run as `active`, then `completed` / `failed`.
Properties
$collection
public
string
$collection
= 'migrations'
$database
public
Database
$database
Methods
__construct()
public
__construct(Database $database[, string $collection = 'migrations' ]) : mixed
Parameters
- $database : Database
-
The low-level client (from
ArangoDB::database()). - $collection : string = 'migrations'
-
The tracking collection name.
append()
Appends a `doctor --apply` audit row — a {@see MigrationKind::DOCTOR} event with a server-generated key, never replayed.
public
append(MigrationAction $action) : void
Parameters
- $action : MigrationAction
-
The audit document (no
_key— the server assigns one).
Tags
applied()
Returns the versions of the migrations already applied on this database — the {@see MigrationKind::MIGRATE} rows keyed by version, used to compute what is pending. An absent collection means "nothing applied yet" (empty map), not an error.
public
applied() : array<string, MigrationAction>
Tags
Return values
array<string, MigrationAction> —The applied migrations, keyed by version (_key).
ensureCollection()
Creates the tracking collection if it does not exist yet — called before the first write of a run.
public
ensureCollection() : void
Tags
remove()
Removes a versioned migration row by version — used by the rollback (`--down`, after running `down()`) and the rescue (`--forget`).
public
remove(string $version) : void
Parameters
- $version : string
-
The migration version (
_key).
Tags
save()
Inserts or updates a versioned migration row (`UPSERT` on `_key`) — used to record a run as `active`, then `completed` / `failed`.
public
save(MigrationAction $action) : void
Parameters
- $action : MigrationAction
-
The tracking document (its
_keyis the version).