xmonader
(Xmonader)
February 7, 2012, 5:37pm
1
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
generates
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()
{
\DBUtil::drop_table('posts');
}
}
redguy
(Maciej Lizewski)
February 7, 2012, 7:42pm
2
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)
oceatoon
(Oceatoon)
February 22, 2012, 2:59pm
3
Hi
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
jacmoe
(Jacob Moen)
February 22, 2012, 3:22pm
4
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.
jacmoe
(Jacob Moen)
February 22, 2012, 3:23pm
5
oceatoon
(Oceatoon)
February 22, 2012, 4:12pm
6
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
jacmoe
(Jacob Moen)
February 23, 2012, 2:35am
7