Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,155 of 9,155 pages
About the help in other languages
All help pages

Migrations: policies, views and events

The policies of the module migration and which views check them, the seven views with their addresses, the dashboard block and its fetch function, the ezpEvent events a run sends with their parameters, and the audit…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/migrations/policies-views-and-events.md

On this page

Migrations: policies, views and events

This page lists everything an administrator grants and a developer listens to around migrations: the policies of the module migration, its views, the dashboard block, the events a run sends and the audit events it writes.

Contents

  1. Policies
  2. Views
  3. The dashboard block and the fetch function
  4. Events a run sends
  5. Audit events
  6. Related pages

Policies

PolicyAllowsChecked by
migration/readthe status, the history, the page of a run, the dry run, the dashboard block, the sidebar panelthe views status, history, log, stream, dryrun
migration/runrun, resume, and Simulate in the dry runthe view run, and dryrun for the simulation
migration/rollbacktake back a run, one migration or an earlier captionthe view rollback
migration/editrecord changes (Setup > Migrations > Recording, see Recording changes), generate migrations from them, and write and change YAML migrations in the editor (Setup > Migrations > Editor)the views recording and editor
migration/remotesadd, change and remove remotes, Test connection (Remotes and deploys)the view remote, and remotes for Test connection
migration/deploya preflight, a deploy, approving a gate, rolling a deploy backthe views deploy and deployment for their buttons

None of them has limitations: each is all or nothing. Only the Administrator role has them in a new installation. Run, resume, simulate and rollback ask "Verify it's you" first (site.ini [ReauthGroup_system], Verify it's you). The console checks no policy: whoever can run ./console on the server can run migrations, as the user migration.ini [RunSettings] RunAsUser or --login=<login>.

To give a role read access in a migration of its own, see Add roles and policies:

$role = \eZRole::fetchByName( 'Site operators' );
$role->appendPolicy( 'migration', 'read' );
\eZRole::expireCache();

Generated reference: Policies of the migration module.

Views

ViewAddressPolicyWhat it showsHelp
status/migration/statusreadevery migration and its state, the lock, the latest runsThe status
history/migration/historyreadevery run with its captions, commit, tag and pushThe history
log/migration/log/<run-id>readone run: its record, migrations and run logThe page of a run
stream/migration/stream/<run-id>readthe live progress of a run, as the run's page reads itThe page of a run
dryrun/migration/dryrunread (run to simulate)the plan, and the simulationDry run
run/migration/runrunthe pending migrations, the switches, starting the runRun
rollback/migration/rollback/<target>rollbacka run, one migration or a caption to restoreRoll back
remotes/migration/remotesread (remotes to test)the remotes, Test connectionRemotes
remote/migration/remote/<id>remotesthe wizard of a remote (new or saved)The wizard
deploy/migration/deployread (deploy to start one)the deploy form and the historyDeploys
deployment/migration/deployment/<deploy-id>read (deploy for a gate or a rollback)one deploy, live per remote, its report, gate and rollbackA deploy's page

The module is Setup > Migrations in the menu (menu.ini, shown to users with migration/read). Generated reference: The migration module. The help button of each view opens the page in the last column.

The dashboard block and the fetch function

The dashboard block migrations (its settings) shows how many migrations are pending or failed, the orphans, the run going on and the last run, for users with migration/read. It reads the fetch function migration/summary (reference), which a template of your own can use too:

{def $migrations = fetch( 'migration', 'summary' )}
{if $migrations.failed}
    <p>{$migrations.failed} migration(s) failed: see Setup > Migrations.</p>
{elseif $migrations.pending}
    <p>{$migrations.pending} migration(s) pending.</p>
{/if}
{undef $migrations}

The keys are pending, failed, orphans, total, ready (the record tables exist), run (the last run), running (a run started in the administration that goes on), lock (who holds the installation lock) and problem. The website sidebar's Migrations panel shows the same (Migrations in the website sidebar).

Events a run sends

The runner notifies ezpEvent listeners, registered in site.ini [Event] Listeners[]=<event>@<callback>. A listener that throws does not stop the run. The parameters, by position:

EventParametersWhen
migration/run/beforestring $runId, string[] $ids, expMigrationContext $contextbefore the first migration of a run
migration/step/beforestring $runId, expMigration $migration, expMigrationContext $contextbefore each migration (and before each down() of a rollback)
migration/step/afterstring $runId, expMigration $migration, array $entry, expMigrationContext $contextafter each, with its entry (state, action, messages, duration)
migration/run/afterstring $runId, array $report, expMigrationContext $contextafter the run, with its report (exp-migration/1)

A listener in an extension, for example one that posts the end of every run to a chat channel:

<?php /* #?ini charset="utf-8"?
# extension/mysite/settings/site.ini.append.php
[Event]
Listeners[]=migration/run/after@mysiteMigrationNotifier::runAfter
*/ ?>
<?php
class mysiteMigrationNotifier
{
    public static function runAfter( $runId, array $report, $context )
    {
        $summary = isset( $report['summary'] ) ? $report['summary'] : array();
        eZLog::write( sprintf( 'migration run %s in %s: exit %d, %d applied, %d failed', $runId,
                               $context->environment(), (int)$report['exit'],
                               isset( $summary['applied'] ) ? (int)$summary['applied'] : 0,
                               isset( $summary['failed'] ) ? (int)$summary['failed'] : 0 ), 'mysite-migrations.log' );
    }
}

Audit events

Every run writes to the audit trail (channel system), enabled in settings/audit.ini [AuditEventSettings] (reference):

EventWritten when
system.migration.runa run ends, with its id, environment, counts and exit code
system.migration.applya migration is applied; also when a changed file is accepted with --force --reason
system.migration.faila migration fails, with its message
system.migration.rollbacka run, a migration or a caption is taken back
system.migration.captiona caption is taken
system.migration.pushthe record of a run is pushed, or the push fails
system.migration.httpan http step sends a request: method, host and path, status (never the query, a header or the body)
system.migration.maila mail step sends a mail: how many recipients (never an address or the text)
system.migration.commanda command step runs a console command: its name and exit code (never its arguments or output)

exp:upgrade writes its own system.upgrade.* events. Read them in the audit console, or send them on through the audit log's sinks (mail, webhook) (The audit trail of runs, The audit trail).

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x