<?php defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_Version_135 extends CI_Migration{

    public function up()	{
        ## Create Table items_categories
        $this->dbforge->add_field(array(
            'id' => array(
                'type' => 'INT',
                'constraint' => 11,
                'null' => FALSE,
                'auto_increment' => TRUE
            ),
            'parent_id' => array(
                'type' => 'INT',
                'constraint' => 11,
                'null' => true,
            ),
            'name' => array(
                'type' => 'VARCHAR',
                'constraint' => 191,
                'null' => FALSE,

            ),
            'description' => array(
                'type' => 'TEXT',
                'null' => TRUE,

            ),
        ));
        $this->dbforge->add_key("id",true);
        $this->dbforge->create_table("items_categories", TRUE);

        $fields = array(
            'category_id' => array(
                'type' => 'INT',
                'constraint' => 11,
                'null' => TRUE,
            ),
        );
        $this->dbforge->add_column('items', $fields);

    }

    public function down() {
        ### Drop table items_categories ##
        $this->dbforge->drop_table("items_categories", TRUE);

        $this->dbforge->drop_column('items', "category_id");
    }
}
