skipthedragon / wp-migrations
Doctrine like Migrations in WordPress.
dev-main
2024-03-15 23:03 UTC
Requires (Dev)
- php: >=8.1
This package is auto-updated.
Last update: 2025-04-20 21:54:14 UTC
README
Heavily inspired by Symfony/Doctrine migrations, this package provides a simple way to manage your WordPress database schema and data.
Installation
composer require skipthedragon/wp-migrations
Pre-requisites
This package requires:
wpdb
(WordPress database)- at least PHP 8.1
Prerequisites
Migrations must:
- be in the migration folder that you specified in the config
- have a unique timestamp in its name
- implement the Migration interface (
WpMigrations\Architecture\Migration
) - have
MigrationV
in its name
Usage
To run the migrations, you can use the following code:
use WpMigrations\service\MigrationManagerService; $config = new \WpMigrations\Architecture\MigrationConfig( 'path/to/migrations', 'WpMigrations\\Migrations\\', 'my_plugin_name' ); $migrationManagerService = new MigrationManagerService($config); $migrationManagerService->migrate();
Check the migrate()
method in service/MigrationManagerService.php
for more options and types of migration.