Last active
October 9, 2015 15:25
-
-
Save n0mad01/5d44a845659e64ba506a to your computer and use it in GitHub Desktop.
CakePHP 3 Sessions Table 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
this: | |
----- | |
CREATE TABLE sessions ( | |
id varchar(40) NOT NULL default '', | |
data text, | |
expires INT(11) NOT NULL, | |
PRIMARY KEY (id) | |
); | |
equals: | |
------- | |
$ bin/cake bake migration CreateSessions id:string:primary data:text expires:integer | |
equals: | |
------- | |
<?php | |
use Migrations\AbstractMigration; | |
class CreateSessions extends AbstractMigration | |
{ | |
public $autoId = false; | |
public function change() | |
{ | |
$table = $this->table('sessions'); | |
$table->addColumn('id', 'string', [ | |
'default' => null, | |
'limit' => 40, | |
'null' => false, | |
]); | |
$table->addColumn('data', 'text', [ | |
'default' => null, | |
'null' => false, | |
]); | |
$table->addColumn('expires', 'integer', [ | |
'default' => null, | |
'limit' => 11, | |
'null' => false, | |
]); | |
$table->addPrimaryKey([ | |
'id', | |
]); | |
$table->create(); | |
} | |
} | |
$ bin/cake migrations migrate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment