Console - Run

After generating or being supplied a set of migrations, you can process them to change the state of your database.

This is the crux of the migrations plugin, allowing migration of schemas up and down the migration chain, offering flexibility and easy management of your schema and data states.

Resetting migrations

The reset subcommand of run allows you to reset your schema back to a fresh installation.

 cake migration run reset 

You can also execute this through the interactive console.

This is initiated by running the migration shell with no commands:

 cake migration 

You are immediately shown a list of all migrations, and the date applied, if applied.

You can choose the c options to "clean" the schema.

Downgrade

To revert your database schema to the version previous to the current state, migrate down:

 cake migration down 

Upgrade

Upgrade your database to the next available migration with the following command:

 cake migration up 

Both upgrade and downgrade operations provide output to indicate the process and result of the migration operation.

Any issues will be reported to you in the console.

Migrations for plugins

To apply a migration that is within a plugin, add the -plugin plugin name switch to your command:


cake migration reset -plugin users
cake migration up -plugin users
cake migration down -plugin users