CodeIgniter Forums
[SOLVED] Migration add primary key - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: [SOLVED] Migration add primary key (/thread-47635.html)



[SOLVED] Migration add primary key - El Forum - 12-15-2011

[eluser]nuclearmaker[/eluser]
how to add primary key in migration? i want to set blog_id as PRIMARY KEY

Code:
public function up()
{
$this->dbforge->add_field(array(
  'blog_id' => array(
   'type' => 'INT',
   'auto_increment' => TRUE
  ),
  'blog_title' => array(
   'type' => 'VARCHAR',
   'constraint' => '100',
  ),
  'blog_description' => array(
   'type' => 'TEXT',
   'null' => TRUE,
  ),
));

$this->dbforge->create_table('blog');
}