-
-
Save mcanvar/ee60c2899f7280180dcfb283182fdd30 to your computer and use it in GitHub Desktop.
Create CodeIgniter Sessions Migration
This file contains hidden or 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
<?php | |
/** | |
* Created by PhpStorm. | |
* User: [email protected] | |
* Date: 22.08.2016 | |
* Time: 04:58 | |
*/ | |
class Migration_Create_Sessions extends CI_Migration { | |
public function up() | |
{ | |
// Drop table 'ci_sessions' if it exists | |
$this->dbforge->drop_table('ci_sessions', TRUE); | |
// Table structure for table 'groups' | |
$this->dbforge->add_field(array( | |
'id' => array( | |
'type' => 'VARCHAR', | |
'constraint' => '40', | |
'null' => FALSE | |
), | |
'ip_address' => array( | |
'type' => 'VARCHAR', | |
'constraint' => '45', | |
'null' => FALSE | |
), | |
'timestamp' => array( | |
'type' => 'INT', | |
'constraint' => '10', | |
'unsigned' => TRUE, | |
'default' => 0, | |
'null' => FALSE | |
), | |
'data' => array( | |
'type' => 'blob', | |
'null' => FALSE | |
) | |
)); | |
$this->dbforge->create_table('ci_sessions'); | |
$this->db->query('CREATE INDEX `ci_sessions_timestamp` ON `ci_sessions` (`timestamp`)'); | |
$this->db->query('ALTER TABLE `ci_sessions` ADD PRIMARY KEY (`id`, `ip_address`)'); | |
} | |
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