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