Oihana PHP Arango

MigrationStore

Read onlyYes

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
author

Marc Alcaraz (ekameleon)

since
1.2.0

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

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
throws
ArangoException

When the request fails.

ReflectionException

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
throws
ArangoException

When the request fails for a reason other than a missing collection.

ReflectionException
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
throws
ArangoException

When the request fails.

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
throws
ArangoException

When the request fails.

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 _key is the version).

Tags
throws
ArangoException

When the request fails.

ReflectionException
On this page

Search results