Elgg  Version master
20170728074645_create_entity_relationships_table.php
Go to the documentation of this file.
1 <?php
2 
5 
6 class CreateEntityRelationshipsTable extends AbstractMigration {
20  public function change() {
21 
22  if ($this->hasTable("entity_relationships")) {
23  return;
24  }
25 
26  $table = $this->table("entity_relationships", [
27  'engine' => "InnoDB",
28  'encoding' => "utf8mb4",
29  'collation' => "utf8mb4_general_ci",
30  ]);
31 
32  $table->addColumn('guid_one', 'integer', [
33  'null' => false,
34  'limit' => MysqlAdapter::INT_BIG,
35  'precision' => 20,
36  'signed' => false,
37  ]);
38 
39  $table->addColumn('relationship', 'string', [
40  'null' => false,
41  'limit' => 50,
42  ]);
43 
44  $table->addColumn('guid_two', 'integer', [
45  'null' => false,
46  'limit' => MysqlAdapter::INT_BIG,
47  'precision' => 20,
48  'signed' => false,
49  ]);
50 
51  $table->addColumn('time_created', 'integer', [
52  'null' => false,
53  'limit' => MysqlAdapter::INT_REGULAR,
54  'precision' => 11,
55  ]);
56 
57  $table->addIndex([
58  'guid_one',
59  'relationship',
60  'guid_two'
61  ], [
62  'name' => "guid_one",
63  'unique' => true,
64  ]);
65 
66  $table->addIndex(['relationship'], [
67  'name' => "relationship",
68  'unique' => false,
69  ]);
70 
71  $table->addIndex(['guid_two'], [
72  'name' => "guid_two",
73  'unique' => false
74  ]);
75 
76  $table->save();
77 
78  }
79 }
$table
Definition: user.php:37
change()
CREATE TABLE prefix_entity_relationships ( id int(11) NOT NULL AUTO_INCREMENT, guid_one bigint(20) un...