Elgg  Version master
20170728075306_create_users_api_sessions_table.php
Go to the documentation of this file.
1 <?php
2 
5 
6 class CreateUsersApiSessionsTable extends AbstractMigration {
18  public function change() {
19 
20  if ($this->hasTable("users_apisessions")) {
21  return;
22  }
23 
24  $table = $this->table("users_apisessions", [
25  'engine' => "MEMORY",
26  'encoding' => "utf8mb4",
27  'collation' => "utf8mb4_general_ci",
28  ]);
29 
30  $table->addColumn('user_guid', 'integer', [
31  'null' => false,
32  'limit' => MysqlAdapter::INT_BIG,
33  'precision' => 20,
34  'signed' => false,
35  ]);
36 
37  $table->addColumn('token', 'string', [
38  'null' => true,
39  'limit' => 40,
40  ]);
41 
42  $table->addColumn('expires', 'integer', [
43  'null' => false,
44  'limit' => MysqlAdapter::INT_REGULAR,
45  'precision' => 11,
46  'after' => 'token'
47  ]);
48 
49  $table->addIndex(['user_guid'], [
50  'name' => "user_guid",
51  'unique' => false,
52  ]);
53 
54  $table->addIndex(['token'], [
55  'name' => "token",
56  'unique' => false,
57  ]);
58 
59  $table->save();
60  }
61 }
$table
Definition: user.php:37
change()
CREATE TABLE prefix_users_apisessions ( id int(11) NOT NULL AUTO_INCREMENT, user_guid bigint(20) unsi...