Skip to content

Instantly share code, notes, and snippets.

@harris21
Created January 19, 2013 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save harris21/4574681 to your computer and use it in GitHub Desktop.
Save harris21/4574681 to your computer and use it in GitHub Desktop.
Create CodeIgniter Sessions Migration
class Migration_Create_Sessions extends CI_Migration {
public function up()
{
$fields = array(
'session_id VARCHAR(40) DEFAULT \'0\' NOT NULL',
'ip_address VARCHAR(45) DEFAULT \'0\' NOT NULL',
'user_agent VARCHAR(120) NOT NULL',
'last_activity INT(10) unsigned DEFAULT 0 NOT NULL',
'user_data text NOT NULL'
);
$this->dbforge->add_field($fields);
$this->dbforge->add_key('session_id', TRUE);
$this->dbforge->create_table('ci_sessions');
$this->db->query('ALTER TABLE `ci_sessions` ADD KEY `last_activity_idx` (`last_activity`)');
}
public function down()
{
$this->dbforge->drop_table('ci_sessions');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment