Elgg  Version 6.1
20170728074729_create_entity_subtypes_table.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class CreateEntitySubtypesTable extends AbstractMigration {
25  public function change() {
26 
27  if ($this->hasTable("entity_subtypes")) {
28  return;
29  }
30 
31  $table = $this->table("entity_subtypes", [
32  'engine' => "InnoDB",
33  'encoding' => "utf8",
34  'collation' => "utf8_general_ci",
35  ]);
36 
37  $table->addColumn('type', 'enum', [
38  'null' => false,
39  'limit' => 6,
40  'values' => [
41  'object',
42  'user',
43  'group',
44  'site'
45  ],
46  ]);
47 
48  $table->addColumn('subtype', 'string', [
49  'null' => false,
50  'limit' => 50,
51  ]);
52 
53  $table->addColumn('class', 'string', [
54  'null' => false,
55  'default' => '',
56  'limit' => 255,
57  ]);
58 
59  $table->addIndex([
60  'type',
61  'subtype'
62  ], [
63  'name' => "type",
64  'unique' => true
65  ]);
66 
67  $table->insert([
68  [
69  'type' => 'object',
70  'subtype' => 'plugin',
71  'class' => 'ElggPlugin',
72  ],
73  [
74  'type' => 'object',
75  'subtype' => 'file',
76  'class' => 'ElggFile',
77  ],
78  [
79  'type' => 'object',
80  'subtype' => 'widget',
81  'class' => 'ElggWidget',
82  ],
83  [
84  'type' => 'object',
85  'subtype' => 'comment',
86  'class' => 'ElggComment',
87  ],
88  [
89  'type' => 'object',
90  'subtype' => 'elgg_upgrade',
91  'class' => 'ElggUpgrade',
92  ],
93  [
94  'type' => 'object',
95  'subtype' => 'admin_notice',
96  'class' => '',
97  ],
98  ]);
99 
100  $table->save();
101  }
102 }
change()
CREATE TABLE prefix_entity_subtypes ( id int(11) NOT NULL AUTO_INCREMENT, type enum(&#39;object&#39;,&#39;user&#39;,&#39;group&#39;,&#39;site&#39;) NOT NULL, subtype varchar(50) NOT NULL, class varchar(255) NOT NULL DEFAULT &#39;&#39;, PRIMARY KEY (id), UNIQUE KEY type (type,subtype) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;.
$table
Definition: user.php:37