-
-
Save ron4stoppable/368f601f7226423f2110cdb212eac24c to your computer and use it in GitHub Desktop.
Create CodeIgniter Sessions Migration
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
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