开发者

DB schema migration tool for CodeIgniter

Is there a good tool for managing changes to MySQL schemas? Either standalone, or integrating with the CodeIgniter 开发者_开发知识库framework. I'm coming at this idea with experience using CakePHP's DB migration tool, so something similar would be great.


There is a Doctrine migrations project among other Doctrine projects.


defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_Add_blog extends CI_Migration {

    public function up()
    {
        $this->dbforge->add_field(array(
            'blog_id' => array(
                'type' => 'INT',
                'constraint' => 5,
                'unsigned' => TRUE,
                'auto_increment' => TRUE
            ),
            'blog_title' => array(
                'type' => 'VARCHAR',
                'constraint' => '100',
            ),
            'blog_description' => array(
                'type' => 'TEXT',
                'null' => TRUE,
            ),
        ));

        $this->dbforge->create_table('blog');
    }

    public function down()
    {
        $this->dbforge->drop_table('blog');
    }

Check it from http://www.codeigniter.com/userguide2/libraries/migration.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜