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

Migrations in the kernel

Exponential 6.0.15 adds migrations to the kernel: changes to an installation (a table, content, a class, a role, a setting) written once in files under version control and applied to every installation of a site in the…

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/features/6.0/migrations.md

On this page

Migrations in the kernel

Exponential 6.0.15 adds migrations to the kernel: changes to an installation (a table, content, a class, a role, a setting) written once in files under version control and applied to every installation of a site in the same order, with a record of what ran where, a caption (backup) before every run, an automatic restore after a failure, and a commit, tag and push of every run's record. Before 6.0.15 such changes were applied by hand or by update scripts, and nothing recorded which ran.

The guide that teaches it is Migrations; start with the tutorial.

Quick start:

./console exp:migration:generate --skeleton add_news_class --apply
./console exp:migration:check
./console exp:migration:migrate              # dry run
./console exp:migration:migrate --apply
./console exp:migration:status

What 6.0.15 adds

PartWhat it is
The kernel's upgrade stepsevery step of exp:upgrade (the kernel's and the extensions') is a migration of the source kernel: listed first by the status and the administration, applied first by a run (stages database and scripts), and nameable in requires
Migration filesYYYYMMDDHHMMSS_name.php in the site's migrations/, in extension/<name>/migrations/ of active extensions and in installed packages; a header of key: value comment lines (description, requires, environments, engines, maintenance, author); ordered by id and by requires
PHP migrationsa namespaced class that extends expMigrationPhp with plan(), up(), optionally down() and detect()
The recordtables exp_migration (one row per migration; also the record of exp:upgrade since 6.0.15) and exp_migration_run (one row per run), made by the upgrade step 6.0.15-migration-tables
The runnerthe installation lock shared with exp:upgrade, one transaction per migration where the engine has one, the run's user, maintenance mode per migration, a checksum guard against changed files, ezpEvent events and audit events
Captionsa caption before every run (reused while nothing changed), one after a run that passed, one of the failed state, and the restore of the pre caption after a failure; the captions are those of exp:upgrade
Rollbacka run (its pre caption), one migration (its down()), or, for experts, any caption
The migrations repositorythe status file status/<environment>.json and the run log runs/<run-id>.log, committed, tagged and pushed after every run; failed pushes retried by the cronjob part migrationpush
Commandsexp:migration:status, :migrate, :dry-run (with --simulate --diff), :rollback, :resume, :caption, :push, :check, :generate; :migrate and :resume take --run-id (the id of the run to start) and --progress (a file the run appends its progress to, one JSON line per event), :rollback takes --progress
Setup > Migrationsthe module migration with the views status, history, log/<run-id>, stream/<run-id> (the live progress), dryrun, run and rollback/<target>; the policies migration/read, run, rollback and edit (Administrator only in a new installation); "Verify it's you" before a run, a resume, a simulation and a rollback
Background runsa run, resume or rollback started in the administration runs as a console process of its own as the signed-in user (expMigrationJob), goes on when the page is closed, and is followed live through its progress file; its files are in var/<site>/migration/jobs/
Dashboard blockmigrations: pending, failed, orphans, the run going on and the last run (fetch function migration/summary)
Recording changesa user's own changes (session) or every change (site-wide window) recorded at the kernel's operation level as the steps of a YAML migration, without personal data; tables exp_migration_recording and exp_migration_recording_event (upgrade step 6.0.15-migration-recording-tables); the commands exp:migration:record:start, :stop, :status, :list, :show, :discard; Setup > Migrations > Recording and the Recording bar (the guide)
Settingssettings/migration.ini: [MigrationSettings], [RunSettings], [CaptionSettings], [RepositorySettings], [AdminSettings] (PhpCliPath, JobHistory, LogBytes)

The building blocks

Class (kernel/classes/migration/)Role
expMigrationthe interface of a migration (id, source, state, plan, up, down)
expMigrationDefinitiona file on disk: name, header, checksum
expMigrationLocatorfinds the files of the site, the extensions and the packages
expMigrationGraphthe order, and the errors of the order (duplicates, missing requirements, cycles)
expMigrationPhpthe base class of a PHP migration
expMigrationContextwhat a run works on: database, user, environment, references, record, lock, log
expMigrationRunnerruns migrations, and takes one back with down()
expMigrationRunFlowcaptions, restore, commit, tag and push around a run
expMigrationCaption, expMigrationRollback, expMigrationResumecaptions, the three rollbacks, resuming a run
expMigrationRecord, expMigrationStatusMirror, expMigrationRepositorythe tables, the files in git, git
expMigrationLockthe installation lock with a holder file (also the lock of exp:upgrade)
expMigrationStatus, expMigrationCheck, expMigrationSimulation, expMigrationGeneratorthe status, the lint, the simulation, the skeleton
expMigrationUpgradeSource, expMigrationUpgradeStepthe kernel's upgrade steps (exp:upgrade) as migrations of the source kernel
expMigrationAdmin, expMigrationJob, expMigrationProgressthe forms and the dashboard summary of Setup > Migrations, the runs started there in the background, their progress file
expMigrationRecording, expMigrationRecorder, expMigrationRecordingEvent, expMigrationRecordingResolver, expMigrationRecordingGeneratorthe recordings and their events, the tap in the audit hook points, an audit event as a migration step, the stable names read from the installation, the plan of a recording

The commands are bin/php/expmigration<name>.php (alias exp:migration:<name>), their code in kernel/private/classes/commands/. Their machine output is exp-migration/1 (--format=json); the exit codes are those of exp:upgrade (0, 1 failed, 2 usage, 3 database unreachable, 4 internal).

Engines

DatabaseTransactionsSimulationCaption and restore
SQLitefullyesyes
PostgreSQLfullyesyes
MySQL/MariaDBdata only (schema changes commit at once)noyes
MongoDBnonenoyes
Oracle (ezoracle)data onlynoa caption needs an export of your own; the restore is by hand (the steps are printed)

Limits in 6.0.15

  • Migrations are written in PHP, in YAML, in SQL (sql, <engine>.sql, mongodb.json) or as INI settings (ini) (Migrations: SQL and settings).
  • A migration run applies the kernel's upgrade steps of the stages database and scripts only; the stages code, libraries and finish stay with exp:upgrade (they are listed as deferred).
  • Setup > Migrations shows, runs and rolls back migrations, records changes and generates a migration of a recording (the policy migration/edit); writing migrations, the other generators and the settings of the migrations repository are done in files and on the console.
  • A migration generated from a recording or from what is there leaves out what no step type repeats (a swap of two locations, workflow triggers, settings of extensions, secret settings) and names it at the top of the file; generating from a diff and the converter of the reference bundle's YAML are not there yet.
  • A run started in the administration needs proc_open and a PHP command line binary (migration.ini [AdminSettings] PhpCliPath); without them the page says so and the console runs it.
  • Commits, tags and pushes need git_manager; without it a run says so and commits nothing.

Settings

Every setting with its default: migration.ini. The cronjob part: migrationpush. Audit events: system.migration.run, .apply, .fail, .rollback, .caption, .push, .record in settings/audit.ini.

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