Hi, is there a migration generator extension available for yii ?
somehow like the one in FuelPHP
$ php oil g model post title:varchar body:text user_id:int
Created model: APPPATH/classes/model/post.php
Created migration: APPPATH/migrations/001_create_posts.php
public function up()
'id' => array('constraint' => 11, 'type' => 'int', 'auto_increment' => true),
'title' => array('constraint' => 50, 'type' => 'varchar'),
'body' => array('type' => 'text'),
'user_id' => array('constraint' => 11, 'type' => 'int'),
'created_at' => array('type' => 'datetime'),
public function down()
Yii uses different approach.
- You generate empty migration by:
yiic migrate create [new_migration_name]
Then you edit this migration (up and down methods) to create/drop structures using similiar methods like those generated with oil
You apply migration to database by:
yiic migrate up
- You generate model from table in db using Gii (application module which provides scaffolding through web interface)
it would be interesting to be able to migrate export a table into a migration format
quite easy generator in fact , but does it already exist ?
This looks quite interesting Generator 4 hmmFixtures
There are some code on the page for migrations in the Yii guide AFAIK.
It’s a console command which takes a schema and spits out a migration script.
I’m going through
that but no sign of export table nore schema migrations, are you sure it’s there
i must be to tired