Elgg  Version 5.1
20170728073706_create_annotations_table.php
Go to the documentation of this file.
1 <?php
2 
5 
6 class CreateAnnotationsTable extends AbstractMigration {
26  public function change() {
27 
28  if ($this->hasTable("annotations")) {
29  return;
30  }
31 
32  $table = $this->table("annotations", [
33  'engine' => "InnoDB",
34  'encoding' => "utf8mb4",
35  'collation' => "utf8mb4_general_ci",
36  ]);
37 
38  $table->addColumn('entity_guid', 'integer', [
39  'null' => false,
40  'limit' => MysqlAdapter::INT_BIG,
41  'precision' => 20,
42  'signed' => false,
43  ]);
44 
45  $table->addColumn('name', 'text', [
46  'null' => false,
47  ]);
48 
49  $table->addColumn('value', 'text', [
50  'null' => false,
51  'limit' => MysqlAdapter::TEXT_LONG,
52  ]);
53 
54  $table->addColumn('value_type', 'enum', [
55  'null' => false,
56  'limit' => 7,
57  'values' => [
58  'integer',
59  'text'
60  ],
61  ]);
62 
63  $table->addColumn('owner_guid', 'integer', [
64  'null' => false,
65  'limit' => MysqlAdapter::INT_BIG,
66  'precision' => 20,
67  'signed' => false,
68  ]);
69 
70  $table->addColumn('access_id', 'integer', [
71  'null' => false,
72  'limit' => MysqlAdapter::INT_REGULAR,
73  'precision' => 11,
74  ]);
75 
76  $table->addColumn('time_created', 'integer', [
77  'null' => false,
78  'limit' => MysqlAdapter::INT_REGULAR,
79  'precision' => 11,
80  ]);
81 
82  $table->addColumn('enabled', 'enum', [
83  'null' => false,
84  'default' => 'yes',
85  'limit' => 3,
86  'values' => [
87  'yes',
88  'no'
89  ],
90  ]);
91 
92  $table->addIndex(['entity_guid'], [
93  'name' => "entity_guid",
94  'unique' => false
95  ]);
96 
97  $table->addIndex(['name'], [
98  'name' => "name",
99  'unique' => false,
100  'limit' => 50,
101  ]);
102 
103  $table->addIndex(['value'], [
104  'name' => "value",
105  'unique' => false,
106  'limit' => 50,
107  ]);
108 
109 
110  $table->addIndex(['owner_guid'], [
111  'name' => "owner_guid",
112  'unique' => false,
113  ]);
114 
115  $table->addIndex(['access_id'], [
116  'name' => "access_id",
117  'unique' => false,
118  ]);
119 
120  $table->save();
121 
122  }
123 }
change()
CREATE TABLE prefix_annotations ( id int(11) NOT NULL AUTO_INCREMENT, entity_guid bigint(20) unsigned...
$table
Definition: user.php:37