Migrations for modules


I really like to initialize database through migrations.

In modules I have wrote, I keep database definition, as an array identical to the one passed to create table.

So in my initial migration, I would like to include migrations from modules, in order to create database with one call from terminal or backend dashboard.

Here is how I currently do it:

 class SomeModule extends CWebModule {

    public $tableName="sometable";

    public function init() {







    public function db() {

        return array(

            "fields" => array(

                "id" => "pk",






while in migrations I add:

class m161224_203337_init extends CDbMigration


    public function up()


        $some = Yii::app()->getModule('counter');

        $structure= $some->db();





main and console configuration has additionally

'import' => array(





'modules' => array(



any easier way ?

(trying to import module inside up() method is not working as Console app does not support it…)