Elgg  Version 6.1
20170728040000_change_table_engine.php
Go to the documentation of this file.
1 <?php
2 
4 
5 class ChangeTableEngine extends AbstractMigration {
6 
7  private $innodb_tables = [
8  'access_collection_membership',
9  'access_collections',
10  'annotations',
11  'api_users',
12  'config',
13  'entities',
14  'entity_relationships',
15  'entity_subtypes',
16  'metadata',
17  'metastrings',
18  'private_settings',
19  'queue',
20  'river',
21  'system_log',
22  'users_remember_me_cookies',
23  'users_sessions',
24  ];
25 
29  public function up() {
30 
31  $prefix = $this->getAdapter()->getOption('table_prefix');
32 
33  foreach ($this->innodb_tables as $table) {
34  if (!$this->hasTable($table)) {
35  continue;
36  }
37 
38  $this->execute("
39  ALTER TABLE {$prefix}{$table}
40  ENGINE=InnoDB
41  ");
42  }
43  }
44 
48  public function down() {
49 
50  $prefix = $this->getAdapter()->getOption('table_prefix');
51 
52  foreach ($this->innodb_tables as $table) {
53  if (!$this->hasTable($table)) {
54  continue;
55  }
56 
57  $this->execute("
58  ALTER TABLE {$prefix}{$table}
59  ENGINE=MyISAM
60  ");
61  }
62 
63  }
64 }
$table
Definition: user.php:37
down()
Changes table engine to MyISAM.
up()
Changes table engine to InnoDb.