Migrations for modules

Hi,

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() {

        $this->setImport(array(

            'some.models.*',

            'some.components.*',

            'some.controllers.*',

        ));

    }


    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();

       $this->createTable($structure);

     }

...

}



main and console configuration has additionally


'import' => array(

        'application.modules.*',

         'application.modules.some.*',

...

and


'modules' => array(

        'some',

...

any easier way ?

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