is there a migration generator ?

Hi, is there a migration generator extension available for yii ?

somehow like the one in FuelPHP

$ php oil g model post title:varchar[50] body:text user_id:int

    Created model: APPPATH/classes/model/post.php

    Created migration: APPPATH/migrations/001_create_posts.php


namespace Fuel\Migrations;

class Create_posts


    public function up()


        \DBUtil::create_table('posts', array(

            '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'),

        ), array('id'));


    public function down()





Yii uses different approach.

  1. You generate empty migration by:

yiic migrate create [new_migration_name]

  1. Then you edit this migration (up and down methods) to create/drop structures using similiar methods like those generated with oil

  2. You apply migration to database by:

yiic migrate up

  1. 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

It’s truly minimal:

A good starting point?