PHPackages                             ludicdrive/wordpress-database-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. ludicdrive/wordpress-database-migrations

ActiveWp-cli-package

ludicdrive/wordpress-database-migrations
========================================

WordPress library for managing database table schema upgrades and data seeding

1.0.5(2y ago)1160GPL-2.0-or-laterPHPPHP &gt;=5.4

Since Jun 1Pushed 2y agoCompare

[ Source](https://github.com/jorop/wordpress-database-migrations)[ Packagist](https://packagist.org/packages/ludicdrive/wordpress-database-migrations)[ RSS](/packages/ludicdrive-wordpress-database-migrations/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Wordpress Database Migrations
=============================

[](#wordpress-database-migrations)

A WordPress library for managing database table schema upgrades and data seeding.

Ever had to create a custom table for some plugin or custom code to use? To keep the site updated with the latest version of that table you need to keep track of what version the table is at. This can get overly complex for lots of tables.

This package is forked from [deliciousbrains/wp-migrations](https://github.com/deliciousbrains/wp-migrations) and incorporates changes from .

You create a new migration PHP file, add your schema update code, and optionally include a rollback method to reverse the change.

Run `wp wdm migrate` on the command line using WP CLI and any migrations not already run will be executed.

The great thing about making database schema and data updates with migrations, is that the changes are file-based and therefore can be stored in version control, giving you better control when working across different branches.

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

[](#requirements)

This package is designed to be used on a WordPress site project, not for a plugin or theme.

It needs to be running PHP 5.4 or higher.

You need to have access to run WP CLI on the server. Typically `wp wdm migrate` will be run as a last stage build step in your deployment process.

### Key Differences from wp-migrations introduced by enhanced-wp-migrations

[](#key-differences-from-wp-migrations-introduced-by-enhanced-wp-migrations)

- Removed support for multiple migration directories. I've made assumption that all of your migration files should be located at one place only. So that the package can follow [SemVer](https://semver.org/) in the migration names and filenames (Similar to [Flyway](https://flywaydb.org/)).
- Individual migrations will be identified with their respective semver number. E.g., `1`, `1.0.1`, `1.1` etc.
- `wp wdm migrate` command will use the version number of the migration instead of the class name. E.g., `wp wdm migrate 2.0.1`
- Migration file name conventions is `.php`. E.g., `1.php`, `1.0.1.php`, `2.1.php` etc. Usually, you can start your migrations from `0.0.1.php`.
- Make sure you put only one class in one migration file.

### Key Differences from enhanced-wp-migrations

[](#key-differences-from-enhanced-wp-migrations)

- Scaffold a migration

### Installation

[](#installation)

- `composer require ludicdrive/wordpress-database-migrations`
- Bootstrap the package by adding `\LudicDrive\WordpressDatabaseMigrations\Database\Migrator::instance();` to an mu-plugin.
- Run `wp wdm migrate --setup` on the server.

#### mu-plugin

[](#mu-plugin)

For a mu-plugin, add a php file (e.g `wp-migrate.php`) in the `mu-plugins` directory in `wp-content`. The name of the file does not matter.
Minimal contents of the file:

```
