Skip to content

Instantly share code, notes, and snippets.

@Muraveiko
Last active August 11, 2017 13:12
Show Gist options
  • Save Muraveiko/eb618e7e834acdcf331e056c4ede90b1 to your computer and use it in GitHub Desktop.
Save Muraveiko/eb618e7e834acdcf331e056c4ede90b1 to your computer and use it in GitHub Desktop.
new table template
<?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