Elgg  Version 5.1
20170728074504_create_api_users_table.php
Go to the documentation of this file.
1 <?php
2 
5 
6 class CreateApiUsersTable extends AbstractMigration {
17  public function change() {
18 
19  if ($this->hasTable("api_users")) {
20  return;
21  }
22 
23  $table = $this->table("api_users", [
24  'engine' => "InnoDB",
25  'encoding' => "utf8mb4",
26  'collation' => "utf8mb4_general_ci",
27  ]);
28 
29  $table->addColumn('api_key', 'string', [
30  'null' => true,
31  'limit' => 40,
32  ]);
33 
34  $table->addColumn('secret', 'string', [
35  'null' => false,
36  'limit' => 40,
37  ]);
38 
39  $table->addColumn('active', 'integer', [
40  'null' => true,
41  'default' => '1',
42  'limit' => MysqlAdapter::INT_REGULAR,
43  'precision' => 11,
44  ]);
45 
46  $table->addIndex(['api_key'], [
47  'name' => "api_key",
48  'unique' => true,
49  ]);
50 
51  $table->save();
52  }
53 }
change()
CREATE TABLE prefix_api_users ( id int(11) NOT NULL AUTO_INCREMENT, api_key varchar(40) DEFAULT NULL...
$table
Definition: user.php:37