Yii2 Migration Tool Just Produces Empty Objects

Hey guys,

this is my first post in this forum, so please be kind :wink:

I just started with Yii2 and it´s very cool so far. Everything works like a charm except the migration console tool.

When I use yii migration/create create_message I have a new file under console/migrations with a yii\db\Migration Object but the function up() is empty and I don´t know why?

Some hints for me?

Cheers,

Sascha

Hi Sascha,

When you create a migration it usually means you want to make some updates to your db that can be run later in other environments as well.

Thus, you have to enter your own command(s) into up() method that will make updates you need.

I suppose you used to some other approach before, as in Phalcon, for example, where creating a migration you’re getting a current state of your db, didn’t you?

Yii2 migrations docs.

Hi Yugene,

thanks for your fast respond.

Yeah, I´m coming from CakePHP and it´s very comfty there. The console tool also recognizes automatically all differents und alters the tables.

It´s too bad that yii doesn´t make the same. Maybe there is an extension for that?

Cheers,

Sascha

Edit: The best I could find: http://www.yiiframework.com/extension/yii2-migration-utility/

Very close to what I´m looking for and it will do the job :)

Yep, seems suitable (haven’t tried it). Though current yii approach works fine for me and feels comfortable to work with.