Elgg  Version 5.1
20170728050000_expand_text_columns_to_longtext.php
Go to the documentation of this file.
1 <?php
2 
5 
6 class ExpandTextColumnsToLongtext extends AbstractMigration {
7 
8  // Columns that change from text to longtext
9  private $text_to_longtext = [
10  'config' => ['value'],
11  'private_settings' => ['value'],
12  ];
13 
17  public function up() {
18 
19  foreach ($this->text_to_longtext as $table => $columns) {
20  if (!$this->hasTable($table)) {
21  continue;
22  }
23 
24  $table = $this->table($table);
25 
26  foreach ($columns as $column) {
27  if ($table->hasColumn($column)) {
28  $table->changeColumn($column, 'text', [
29  'limit' => MysqlAdapter::TEXT_LONG,
30  ]);
31  }
32  }
33 
34  $table->save();
35  }
36  }
37 
41  public function down() {
42 
43  foreach ($this->text_to_longtext as $table => $columns) {
44  if (!$this->hasTable($table)) {
45  continue;
46  }
47 
48  $table = $this->table($table);
49 
50  foreach ($columns as $column) {
51  if ($table->hasColumn($column)) {
52  $table->changeColumn($column, 'text', [
53  'limit' => MysqlAdapter::TEXT_REGULAR,
54  ]);
55  }
56  }
57 
58  $table->save();
59  }
60  }
61 }
$column
Definition: add.php:10
down()
Shirnk certain columns from longtext to text.
$columns
Definition: table.php:30
$table
Definition: user.php:37
up()
Expand certain columns from text to longtext.