logo

Documentation: Migrations

is a script whose only purpose is to use Migrations API in running as well as generating migration scripts. All classes subject of migration must be located in migrations folder, use global namespace and implement . Running this script also requires a solution that keeps track of migrations outcome already set. For more info, check Tutorial!

Generating Migrations

To generate migrations, open console and run:

php migrations.php generate

This will:

  1. create a new file & class called VersionTIMESTAMP, where TIMESTAMP uses YmdHis date format
  2. class will implement
  3. developers will need to fill generated no-body up and, optionally, down methods with logic

Running Migrations

To run migrations on console go to your project root, open console and run:

php migrations.php

This will:

  1. loop through all classes in migrations folder (ordered by name asc)
  2. instances them
  3. if up ran already AND outcome was a success, CONTINUES to next migration
  4. executes up method
  5. displays results collected in console

To learn more how to write migrations, check Tutorial!

×