Download the PHP package pinkcrab/perique-migration without Composer
On this page you can find all versions of the php package pinkcrab/perique-migration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pinkcrab/perique-migration
More information about pinkcrab/perique-migration
Files in pinkcrab/perique-migration
Package perique-migration
Short Description A module for the Perique Framework which makes use of the PinkCrab Table Builder and PinkCrab Migration libraries.
License MIT
Homepage https://pinkcrab.co.uk
Informations about the package perique-migration
Perique - Migrations
A wrapper around various PinkCrab libraries which make it easier to run DB migrations from a plugin created using the Perique Framework.
Why?
There already exists a WPDB Migrations system written by PinkCrab for use in any WordPress plugin or even theme. However working this into Perique required building a small little isolated workflow due to the nature of how the Perique Registration Process works and how WordPress handles plugin events such as Activation, Deactivation and Uninstalling.
So to make it more seamless adding Database Migrations to Perique, we have created this library to help.
Depends on
As mentioned this library acts more of a bridge for the following packages.
Setup
Creation of Migrations
To create database migrations, the Migration
abstract class must be extended.
Full Migration model references below Example Plugin
Example of table using Perique App Config for table names.
Create the Migrations service
The Perique Migrations Module requires the Plugin Life Cycle to be added to the Perique App. This is to ensure that the migrations are run at the correct time.
Migration Model
All models must extend from the (
abstract
)PinkCrab\Perique\Migration\Migration
class
Methods
__construct(...$deps)
@param mixed ...$deps Injected via the DI Container
You can inject any dependencies you need, so long as they either be inferred by the Type or has the rules define in the DI Rules. See the di container docs for more details
table_name(): string
@return string
@required method
This should return the final name for the table. This can be defined as a string literal or via an injected dependency (such as 'App_Config')
schema( Schema $schema_config ): void
@param PinkCrab\Table_Builder\Schema $schema
@return null @required method
This allows for the definition of the tables schema. Please see the WPDB Migration and WPDB Table Builder libraries for more details
seed( array $seeds ): array
@param array<int, array<string, mixed>> $seeds
@return array<int, array<string, mixed>>
Returns the data used to populate the table with. Should be returned as an array or arrays with matching column (key) and value pairs.
drop_on_deactivation(): bool
@return bool
Depending on the return value, the table can be dropped on deactivation. Defaults to FALSE
drop_on_uninstall(): bool
@return bool
Depending on the return value, the table can be dropped on uninstall. Defaults to FALSE
seed_on_inital_activation(): bool
@return bool
Depending on the return value, will populate tables with defined seeded data Defaults to TRUE
Tables are only seeded once, even in the event of a later update.
Change Log
- 2.0.0 - Support for Perique V2.*
- 1.0.0 - Initial Release (Supports Perique V1.2-1.4)
- 0.1.1 - Update dependencies and GH Action pipelines.
- 0.1.0 - Docs added, sample project created.
- 0.1.0-rc2 - Now uses Perique Plugin Life Cycle 0.2 and removes unneeded files when used as a lib via gitattributes
- 0.1.0-rc1 Inital BETA release.
All versions of perique-migration with dependencies
pinkcrab/perique-framework-core Version 2.0.*
pinkcrab/wp-db-migrations Version ^1.0
pinkcrab/perique-plugin-lifecycle Version 2.0.*