开发者

DB schema migration tool for CodeIgniter

开发者 https://www.devze.com 2023-03-19 23:39 出处:网络
Is there a good tool for managing changes to MySQL schemas? Either standalone, or integrating with the CodeIgniter 开发者_开发知识库framework.

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

精彩评论

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