Skip to content

Instantly share code, notes, and snippets.

@ron4stoppable
Forked from harris21/Migration Create Sessions
Last active June 28, 2018 11:07
Show Gist options
  • Save ron4stoppable/368f601f7226423f2110cdb212eac24c to your computer and use it in GitHub Desktop.
Save ron4stoppable/368f601f7226423f2110cdb212eac24c to your computer and use it in GitHub Desktop.
Create CodeIgniter Sessions Migration
class Migration_Create_Sessions extends CI_Migration {
// The session table structure changed for CI 3.0
public function up()
{
$fields = array(
'id VARCHAR(40) DEFAULT \'0\' NOT NULL',
'ip_address VARCHAR(45) DEFAULT \'0\' NOT NULL',
'timestamp INT(10) unsigned DEFAULT 0 NOT NULL',
'data blob NOT NULL'
);
$this->dbforge->add_field($fields);
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('ci_sessions');
$this->db->query('ALTER TABLE `ci_sessions` ADD KEY `ci_sessions_timestamp` (`timestamp`)');
}
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