<?php

/**
 * @class m121105_155927_tbl_sectores_tbl_sectores_areas_funcionales
 * @var $this CDbMigration
 * @package application.migrations
 */

class m121105_155927_tbl_sectores_tbl_sectores_areas_funcionales extends CDbMigration {

    public function safeUp() {
        $this->createTable('tbl_sectores', array(
            'id' => 'pk',
            'descripcion' => 'string NOT NULL',
        ), 'ENGINE=InnoDB CHARSET=utf8');

        $this->createTable('tbl_sectores_areas_funcionales', array(
            'id' => 'pk',
            'id_sector' => 'integer NOT NULL',
            'descripcion' => 'string NOT NULL',
        ), 'ENGINE=InnoDB CHARSET=utf8');
        
        $this->addForeignKey('fk_sectores_areas_funcionales_1', 'tbl_sectores_areas_funcionales', 'id_sector', 'tbl_sectores', 'id', 'CASCADE', 'CASCADE');
    }

    public function safeDown() {
        $this->dropForeignKey('fk_sectores_areas_funcionales_1', 'tbl_sectores_areas_funcionales');
        $this->dropTable('tbl_sectores_areas_funcionales');
        $this->dropTable('tbl_sectores');
    }

}