PHPackages                             korvir/wp-migrations - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. korvir/wp-migrations

ActiveLibrary[API Development](/categories/api)

korvir/wp-migrations
====================

Simple migration runner for WordPress

1.2.1(2mo ago)119MITPHPPHP &gt;=7.4CI failing

Since Feb 5Pushed 2mo agoCompare

[ Source](https://github.com/Korvir/wp-migrations)[ Packagist](https://packagist.org/packages/korvir/wp-migrations)[ RSS](/packages/korvir-wp-migrations/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (4)Versions (21)Used By (0)

Simple WP Migrations
====================

[](#simple-wp-migrations)

Simple, explicit database migrations for WordPress via WP-CLI.

`korvir/wp-migrations` is a lightweight migration system inspired by Laravel, but focused on WordPress + MySQL/MariaDB.

Requirements
------------

[](#requirements)

- PHP 7.4+
- WordPress 5.5+
- MySQL/MariaDB
- WP-CLI

Install
-------

[](#install)

```
composer require korvir/wp-migrations
```

Quick Start
-----------

[](#quick-start)

Create a migration:

```
wp migrations add create_users_table
```

Run pending migrations:

```
wp migrations migrate
```

Check status:

```
wp migrations status
```

Rollback last batch:

```
wp migrations rollback
```

Commands
--------

[](#commands)

CommandDescription`wp migrations install`Create migrations table.`wp migrations add `Create migration file from stub.`wp migrations migrate []`Run pending migrations.`wp migrations rollback`Roll back last batch.`wp migrations status`Show migration status table.`wp migrations reset`Roll back all executed migrations.`wp migrations fresh`Reset and run all pending migrations.`wp migrations stub:publish`Publish package stubs to project.### Command Options

[](#command-options)

`add`

- `--path=`: custom migrations path.

`migrate`

- `[]`: run one specific migration.
- `--only=`: comma-separated filename fragments to include.
- `--except=`: comma-separated filename fragments to exclude.
- `--step=`: run only next N pending migrations.
- `--path=`: custom migrations path.
- `--pretend`: dry-run (print migrations without executing).
- `--force`: skip production confirmation.

`rollback`

- `--step=`: rollback N latest executed migrations (ignores batch boundary).
- `--pretend`: dry-run.

`reset`

- `--path=`
- `--pretend`

`fresh`

- `--path=`
- `--pretend`

Notes:

- `--only` and `--except` are mutually exclusive.
- In `production` environment, `migrate` asks for confirmation unless `--force` is provided.

Migration File Structure
------------------------

[](#migration-file-structure)

Use `MigrationInterface`:

```
