Last active
August 11, 2017 13:12
-
-
Save Muraveiko/eb618e7e834acdcf331e056c4ede90b1 to your computer and use it in GitHub Desktop.
new table template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('BASEPATH') OR exit('No direct script access allowed'); | |
class Migration_ extends CI_Migration { | |
protected $tableName = ''; | |
public function up() { | |
$this->dbforge->add_field(array( | |
'id' => array( | |
'type' => 'int', | |
'null' => FALSE, | |
'constraint' => "11", | |
'unsigned' => FALSE, | |
'auto_increment' => TRUE, | |
'unique' => FALSE, | |
), | |
'name' => array( | |
'type' => 'varchar', | |
'null' => TRUE, | |
'constraint' => "255", | |
'unsigned' => FALSE, | |
'auto_increment' => FALSE, | |
'unique' => FALSE, | |
) | |
)); | |
$this->dbforge->add_key("id",TRUE); | |
$this->dbforge->create_table($this->tableName, TRUE); | |
$this->db->query('ALTER TABLE `'.$this->tableName.'` ENGINE = MyISAM'); | |
} | |
public function down() | |
{ | |
$this->dbforge->drop_table($this->tableName, TRUE); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment