Elgg  Version 5.1
20170728074600_create_entities_table.php
Go to the documentation of this file.
1 <?php
2 
5 
6 class CreateEntitiesTable extends AbstractMigration {
29  public function change() {
30 
31  if ($this->hasTable("entities")) {
32  return;
33  }
34 
35  $table = $this->table("entities", [
36  'id' => false,
37  'primary_key' => ["guid"],
38  'engine' => "InnoDB",
39  'encoding' => "utf8mb4",
40  'collation' => "utf8mb4_general_ci",
41  ]);
42 
43  $table->addColumn('guid', 'integer', [
44  'null' => false,
45  'limit' => MysqlAdapter::INT_BIG,
46  'precision' => 20,
47  'signed' => false,
48  'identity' => 'enable',
49  ]);
50 
51  $table->addColumn('type', 'enum', [
52  'null' => false,
53  'limit' => 6,
54  'values' => [
55  'object',
56  'user',
57  'group',
58  'site',
59  ],
60  ]);
61 
62  $table->addColumn('subtype', 'integer', [
63  'null' => true,
64  'limit' => MysqlAdapter::INT_REGULAR,
65  'precision' => 11,
66 
67  ]);
68 
69  $table->addColumn('owner_guid', 'integer', [
70  'null' => false,
71  'limit' => MysqlAdapter::INT_BIG,
72  'precision' => 20,
73  'signed' => false,
74  ]);
75 
76  $table->addColumn('container_guid', 'integer', [
77  'null' => false,
78  'limit' => MysqlAdapter::INT_BIG,
79  'precision' => 20,
80  'signed' => false,
81  ]);
82 
83  $table->addColumn('access_id', 'integer', [
84  'null' => false,
85  'limit' => MysqlAdapter::INT_REGULAR,
86  'precision' => 11,
87  ]);
88 
89  $table->addColumn('time_created', 'integer', [
90  'null' => false,
91  'limit' => MysqlAdapter::INT_REGULAR,
92  'precision' => 11,
93  ]);
94 
95  $table->addColumn('time_updated', 'integer', [
96  'null' => false,
97  'limit' => MysqlAdapter::INT_REGULAR,
98  'precision' => 11,
99  ]);
100 
101  $table->addColumn('last_action', 'integer', [
102  'null' => false,
103  'default' => '0',
104  'limit' => MysqlAdapter::INT_REGULAR,
105  'precision' => 11,
106  ]);
107 
108  $table->addColumn('enabled', 'enum', [
109  'null' => false,
110  'default' => 'yes',
111  'limit' => 3,
112  'values' => [
113  'yes',
114  'no'
115  ],
116  ]);
117 
118  $table->addIndex(['type'], [
119  'name' => "type",
120  'unique' => false,
121  ]);
122 
123  $table->addIndex(['subtype'], [
124  'name' => "subtype",
125  'unique' => false,
126  ]);
127 
128  $table->addIndex(['owner_guid'], [
129  'name' => "owner_guid",
130  'unique' => false,
131  ]);
132 
133  $table->addIndex(['container_guid'], [
134  'name' => "container_guid",
135  'unique' => false,
136  ]);
137 
138  $table->addIndex(['access_id'], [
139  'name' => "access_id",
140  'unique' => false,
141  ]);
142 
143  $table->addIndex(['time_created'], [
144  'name' => "time_created",
145  'unique' => false,
146  ]);
147 
148  $table->addIndex(['time_updated'], [
149  'name' => "time_updated",
150  'unique' => false,
151  ]);
152 
153  $table->save();
154 
155  }
156 }
change()
CREATE TABLE prefix_entities ( guid bigint(20) unsigned NOT NULL AUTO_INCREMENT, type enum(&#39;object&#39;...
$table
Definition: user.php:37