Contributing database schema changes

Database Migrations

Elgg uses Phinx to manage the database migrations.

Create a migration

To create a new migration run the following in your console:

vendor/bin/phinx create -c engine/schema/migrations.php MigrationClassName

This will generate a timestamped skeleton migration in engine/schema/migrations/. Follow Phinx documentation to call the necessary methods to modify the database tables.

Executing a migration

Migrations are executed every time your run upgrade.php. If you would like to execute migrations manually, you can do so via the command line:

// When Elgg is the root project
vendor/bin/phinx migrate -c engine/schema/migrations.php

// When Elgg is installed as a Composer dependency
vendor/bin/phinx migrate -c vendor/elgg/elgg/engine/schema/migrations.php

Check Phinx documentation for additional flags that allow you to run a single migration or a set of migrations within a time range.