PHPackages                             erikgreasy/wp-db-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. [Database &amp; ORM](/categories/database)
4. /
5. erikgreasy/wp-db-migrations

ActiveLibrary[Database &amp; ORM](/categories/database)

erikgreasy/wp-db-migrations
===========================

Databse migrations for WordPress inspired by Laravel framework.

0.1.1(3y ago)14PHP

Since Oct 20Pushed 3y ago1 watchersCompare

[ Source](https://github.com/erikgreasy/wp-db-migrations)[ Packagist](https://packagist.org/packages/erikgreasy/wp-db-migrations)[ RSS](/packages/erikgreasy-wp-db-migrations/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

WordPress database migrations
=============================

[](#wordpress-database-migrations)

*Databse migrations for WordPress inspired by Laravel framework.*

Installation
============

[](#installation)

There are few ways you can install WP DB migrations:

1. Install as a mu-plugin.
--------------------------

[](#1-install-as-a-mu-plugin)

Download the latest release ZIP and extract it into your mu-plugins. You will need some type of must-use plugins autoloader in order for this to work, for example [Bedrock Autoloader](https://github.com/roots/bedrock-autoloader).

2. Install as a regular plugin
------------------------------

[](#2-install-as-a-regular-plugin)

Download the latest release ZIP and extract it into your plugins, or install via wp-admin plugins section.

Getting started
===============

[](#getting-started)

Registering your migrations folders
-----------------------------------

[](#registering-your-migrations-folders)

When running the migrations with WP CLI command, the plugin scans all folders that are registered as "migrations folders". Migration folder is basically a folder in your plugin/theme, where your migrations are stored.

The plugin supports registering multiple migrations folders, so you can have separate migration folder for mulitple plugins.

To register a new migration folder, use the following WP filter:

```
add_filter('dbmigrator_migrations_dirs', function($migrationDirs) {
    $migrationDirs[] = __DIR__ . '/my_plugin_migrations';

    return $migrationDirs;
});
```

Creating your first migration file
----------------------------------

[](#creating-your-first-migration-file)

Migration file is just a PHP file, which follows specific structure, so the plugin can scan this file and run.

### Migration structure

[](#migration-structure)

Simple example migration may look like this:

```
