Skip to main content

migration:listen

Runs migrations as soon as they are queued with PATCH /migration/<uuid>. Queuing a migration sends a message to RabbitMQ, and this command waits for these messages: nothing is polled, the databases are only asked when a message arrives. The message is only a trigger. The migration is checked again before it runs, so a migration which is not queued anymore, which is run by somebody else or whose type is locked right now is skipped; outdated or repeated messages are harmless.

Like cron:finalize-uploads, the command stays attached to its queue until its time budget (MAX_WORK_TIME_IN_S, 2 minutes and 45 seconds when scheduled) is used up, and it is scheduled again every 3 minutes. Use --drain to terminate as soon as the queue is empty instead, which is also what happens when the command is run by hand in a terminal.

If a message is lost, e.g. because RabbitMQ was not reachable when the migration was queued, the sweep of migration:run runs the migration instead.

Every API instance schedules this command on its own (see Background tasks). It is skipped (successfully) while a backup is being loaded or the database is being reset.

Help

php bin/console migration:listen --help
Description:
  Runs migrations as soon as they are queued.

Usage:
  migration:listen [options]

Options:
      --drain           Terminates as soon as the queue is empty instead of waiting for new migrations until the time budget is used up.
  -h, --help            Display help for the given command. When no command is given display help for the list command
      --silent          Do not output any message
  -q, --quiet           Only errors are displayed. All other output is suppressed
  -V, --version         Display this application version
      --ansi|--no-ansi  Force (or disable --no-ansi) ANSI output
  -n, --no-interaction  Do not ask any interactive question
  -e, --env=ENV         The Environment name. [default: "prod"]
      --no-debug        Switch off debug mode.
      --profile         Enables profiling (requires debug).
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Example

php bin/console migration:listen --drain
    ▄
  ▄▀ ▀▄  Ember Nexus API
   ▀█▀   v0.3.0, production mode

  Migration listen

▶ Handled 0 announced migration(s).