Elgg  Version 6.1
20170728075454_create_users_sessions_table.php
Go to the documentation of this file.
1 <?php
2 
5 
6 class CreateUsersSessionsTable extends AbstractMigration {
16  public function change() {
17 
18  if ($this->hasTable("users_sessions")) {
19  return;
20  }
21 
22  $table = $this->table("users_sessions", [
23  'id' => false,
24  'primary_key' => ["session"],
25  'engine' => "InnoDB",
26  'encoding' => "utf8mb4",
27  'collation' => "utf8mb4_general_ci",
28  ]);
29 
30  $table->addColumn('session', 'string', [
31  'null' => false,
32  'limit' => MysqlAdapter::TEXT_SMALL,
33  'encoding' => "utf8",
34  'collation' => "utf8_general_ci",
35  ]);
36 
37  $table->addColumn('ts', 'integer', [
38  'null' => false,
39  'default' => '0',
40  'limit' => MysqlAdapter::INT_REGULAR,
41  'precision' => 11,
42  'signed' => false,
43  ]);
44 
45  $table->addColumn('data', 'blob', [
46  'null' => true,
47  'limit' => MysqlAdapter::BLOB_MEDIUM,
48  ]);
49 
50  $table->addIndex(['ts'], [
51  'name' => "ts",
52  'unique' => false,
53  ]);
54 
55  $table->save();
56 
57  }
58 }
change()
CREATE TABLE prefix_users_sessions ( session varchar(255) CHARACTER SET utf8 NOT NULL, ts int(11) unsigned NOT NULL DEFAULT &#39;0&#39;, data mediumblob, PRIMARY KEY (session), KEY ts (ts) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;.
$table
Definition: user.php:37