Skip to main content

GravityKit\GravityMigrate\CLI\Migrate

Migrate Gravity Forms + GravityKit data (forms, entries, Views, and the pages that

embed them) from the command line: export a portable bundle, import one, inspect one, or reset stuck migration state -- and move forms between Gravity Forms and the other form plugins (plugins, to, from).

Both export and import drive the same batch state machine the browser UI uses (the Export/Import AJAX route closures), run to completion synchronously. The AJAX die-on-error handlers are disabled under WP-CLI (see Import::set_error_environment()).

to and from call the same provider objects the wizard's AJAX controllers call, through \ExternalMigration. They deliberately do not go through those controllers: validate_request() requires a nonce and CoreHelpers::process_return() sends JSON and dies, neither of which survives WP-CLI. The checks the controllers apply are applied there instead.

Since:

  • 1.2.0
  • %ver% Adds plugins, toandfrom.

Source: src/CLI/Migrate.php:39

Details

  • Kind: class
  • Namespace: GravityKit\GravityMigrate\CLI
  • Extends: WP_CLI_Command

Methods

MethodDescription
export()Exports Gravity Forms + GravityKit data to a portable ZIP bundle.
import()Imports a GravityMigrate ZIP bundle into this site.
inspect()Inspects a bundle without importing: prints its forms, data types, and source URL,
status()Reports current migration state: whether an import lock is held (and whether
reset()Clears stuck migration state: temporary tables, extracted import files, and the
plugins()Lists the form plugins this site can move forms to and from.
to()Moves Gravity Forms forms into another form plugin.
from()Brings forms from another form plugin into Gravity Forms.

Method Reference

export()

public function export( $args, $assoc_args )

Exports Gravity Forms + GravityKit data to a portable ZIP bundle.

OPTIONS

--forms=<ids> : Comma-separated form IDs to export, or "all".

default: entries,views,posts

[--date-start=<Y-m-d>] : Only export entries created on or after this date.

[--date-end=<Y-m-d>] : Only export entries created on or before this date.

[--password=<password>] : Encrypt the ZIP (AES-256).

[--include-files] : Package the uploaded files the forms and entries reference INSIDE the bundle, rather than leaving the importing site to download each one from here. Use it when this site is not reachable from the destination -- a local development site, a site behind HTTP auth, or one about to be switched off. The bundle gets much larger, and files beyond 80% of this site's own upload limit are left out and still downloaded on import; filter gk/gravitymigrate/export/file-size-limit to change that.

[--public-url=<url>] : Rewrite this site's origin to <url> in exported file-upload URLs, page content, and info.json (src_url/uploads_dir). Use it when exporting from a site whose stored URL is not reachable from the destination (e.g. a demo clone's internal host) so uploads download on import. The URL must be public and resolvable from the importing server.

[--output=<path>] : Copy the finished ZIP to this path (the export directory is auto-deleted after 3 hours).

[--porcelain] : Output only the resulting ZIP path.

[--format=<format>] : Summary format.

default: table options:

  • table
  • json

EXAMPLES

wp gk migrate export --forms=2 --data=entries,views,posts \
--public-url=https://gravityview--abc123.demo.gravitykit.com \
--output=/srv/bundles/abc123.zip --porcelain

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:155

import()

public function import( $args, $assoc_args )

Imports a GravityMigrate ZIP bundle into this site.

Imports are not resumable: a failed import prints the form IDs it committed before the failure, so you can remove them and re-run.

OPTIONS

<zip> : Path to the GravityMigrate export ZIP.

default: all

[--password=<password>] : ZIP password if it was encrypted.

[--skip-uploads] : Do not download entry file uploads.

[--download-timeout=<secs>] : Per-hop timeout for downloading a linked entry file upload. Overrides the gk/gravitymigrate/import/download-timeout filter (default 300 seconds).

[--max-download-bytes=<n>] : Maximum bytes accepted for a single downloaded entry file upload. Overrides the gk/gravitymigrate/import/max-download-bytes filter (default 100 MB).

[--max-dump-file-size=<n>] : Maximum allowed size, in bytes, of the bundle's SQL dump file. Overrides the gk/gravitymigrate/import/max-dump-file-size filter (default 2 GB).

[--format=<format>] : Summary format.

default: table options:

  • table
  • json

[--yes] : Skip the confirmation prompt (import writes into Gravity Forms tables).

[--porcelain] : Output only the newly-created form IDs, one per line, for scripting.

EXAMPLES

wp gk migrate import bundle.zip --user=admin --yes

wp gk migrate import bundle.zip --user=admin --yes --porcelain

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:338

inspect()

public function inspect( $args, $assoc_args )

Inspects a bundle without importing: prints its forms, data types, and source URL,

and whether its upload URLs will resolve from this site.

OPTIONS

<zip> : Path to the GravityMigrate export ZIP.

[--password=<password>] : ZIP password if encrypted.

[--format=<format>] : Output format.

default: table options:

  • table
  • json

EXAMPLES

wp gk migrate inspect bundle.zip

wp gk migrate inspect bundle.zip --format=json

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:511

status()

public function status( $args, $assoc_args )

Reports current migration state: whether an import lock is held (and whether

it's stale), whether a crashed import is saved for resume, and whether an export has state left over to clean up.

While a CLI-driven import holds the lock, also reports its live progress from the record wp gk migrate import persists after each engine step: the phase, current/total counts with a percentage, seconds since the record last advanced (the is-it-stuck signal), and a rough ETA once a rate is derivable.

OPTIONS

[--watch] : Re-render the status every 2 seconds while the import runs, then print a final line and exit once it completes. A lock that stops advancing is given a further minute before the watch gives up on it, since a single long step ages the lock past its timeout while the import is still alive. Cannot be combined with --format=json.

[--format=<format>] : Output format.

default: table options:

  • table
  • json

EXAMPLES

wp gk migrate status
wp gk migrate status --format=json
wp gk migrate status --watch

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:622

reset()

public function reset( $args, $assoc_args )

Clears stuck migration state: temporary tables, extracted import files, and the

import/export progress options.

OPTIONS

[--yes] : Skip the confirmation prompt.

EXAMPLES

wp gk migrate reset --yes

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:843

plugins()

public function plugins( $args, $assoc_args )

Lists the form plugins this site can move forms to and from.

One row per plugin, with a column for each direction: a plugin can be readable and not writable, because each platform states its own requirements per direction. Where a direction is unavailable, reason names what is missing rather than leaving "no" to be guessed at.

A direction is listed only to a user the wizard would list it to, and the two are gated differently: seeing Gravity Forms forms opens the to column, creating them opens from (\Permission::readable_directions()). So a view-only login gets the destinations it may export to and no from column at all, rather than the import half the wizard refuses it on screen.

OPTIONS

[--available] : Only list plugins this site can actually use, in at least one listed direction.

[--format=<format>] : Output format.

default: table options:

  • table
  • json
  • csv
  • yaml
  • count
  • ids

EXAMPLES

wp gk migrate plugins

wp gk migrate plugins --available --format=ids

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:912

to()

public function to( $args, $assoc_args )

Moves Gravity Forms forms into another form plugin.

Runs the same migration the wizard's "Move forms to another plugin" path runs, one form at a time, and applies the same permission checks: WP-CLI runs as --user=&lt;who&gt;, so viewing Gravity Forms forms and creating forms in the destination plugin are both required, exactly as they are on screen.

Warnings the migration produces are printed as it goes. Some of them can only exist after a form has been written -- WS Form's exporter asks the installed WS Form for db_conditional_repair() once the form exists -- so they appear against the form they belong to rather than in the dry run.

OPTIONS

<plugin> : The destination form plugin. Run wp gk migrate plugins for the list.

--forms=<ids> : Comma-separated Gravity Forms form IDs to move, or "all". "all" means every ACTIVE, untrashed form -- the set the wizard offers -- and a deactivated or trashed form is refused even when its ID is named. (wp gk migrate export --forms=all means something wider: there "all" includes inactive and trashed forms.)

[--dry-run] : Report what would happen to each field and change nothing.

[--format=<format>] : Output format. Both machine formats answer about the forms that went across, not the ones that were asked about: count is how many did, and ids is the IDs of the forms created in the destination plugin -- or, with --dry-run, how many forms were checked and their IDs. A form that failed is in neither. json carries every form, including its failure.

default: table options:

  • table
  • json
  • count
  • ids

[--yes] : Skip the confirmation prompt (a real run creates forms in the destination plugin). Required with any --format but table, which is the only one with somewhere to ask.

EXAMPLES

wp gk migrate to contact-form-7 --forms=all --dry-run

wp gk migrate to ninja-forms --forms=3,5 --user=admin --yes

wp gk migrate to wpforms --forms=all --user=admin --yes --format=ids

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:1019

from()

public function from( $args, $assoc_args )

Brings forms from another form plugin into Gravity Forms.

Runs the same migration the wizard's "Bring forms into Gravity Forms" path runs, one form at a time, and applies the same permission checks: creating Gravity Forms forms is required, exactly as it is on screen.

OPTIONS

<plugin> : The form plugin to read from. Run wp gk migrate plugins for the list.

--forms=<ids> : Comma-separated form IDs in THAT plugin, or "all". "all" means every form that plugin lists, which is the set the wizard offers; an ID it does not list is refused.

[--dry-run] : Report what would happen to each field and change nothing.

[--format=<format>] : Output format. Both machine formats answer about the forms that went across, not the ones that were asked about: count is how many did, and ids is the IDs of the Gravity Forms forms created -- or, with --dry-run, how many forms were checked and their IDs. A form that failed is in neither. json carries every form, including its failure.

default: table options:

  • table
  • json
  • count
  • ids

[--yes] : Skip the confirmation prompt (a real run creates Gravity Forms forms). Required with any --format but table, which is the only one with somewhere to ask.

EXAMPLES

wp gk migrate from ninja-forms --forms=all --dry-run

wp gk migrate from contact-form-7 --forms=2 --user=admin --yes

Parameters

NameTypeDefaultDescription
$args
$assoc_args

Source: src/CLI/Migrate.php:1068