Yii provides a set of migration command line tools that allow you to:

  • create new migrations;
  • apply migrations;
  • revert migrations;
  • re-apply migrations;
  • show migration history and status.

All these tools are accessible through the command yii migrate. In this section we will describe in detail how to accomplish various tasks using these tools. You may also get the usage of each tool via the help command yii help migrate.


Add the package to your composer.json:

and run composer update or alternatively run composer require bizley/migration


Add the following in your configuration file (preferably console configuration file):


Run console command

php yii migration <table_name>

to create migration for DB table .

You can create multiple migrations for many tables at once:

php yii migration <table_name1>,<table_name2>,<table_name3>


–migrationPath (default ‘@app/migrations’) Directory storing the migration classes.

–templateFile (default ‘@vendor/bizley/migration/src/views/migration.php’) Template file for generating new migrations.

–useTablePrefix (default true) Whether the table names generated should consider the tablePrefix setting of the DB connection.

–db (default ‘db’) Connection|array|string the DB connection object or the application component ID of the DB connection to use when creating migrations.



Prakash S

Prakash S

I would like to introduce myself as a Software professional opting for the career in software industry. I'm Prakash S, a MCA graduate and trained as industry level practice for Software technology. Basically I am a PHP Developer but now days exploring more in HTML5, CSS, AngularJS and jQuery libraries.