Elgg  Version master
20230606155735_add_delete_columns_to_entities_tables.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
4 use Phinx\Db\Adapter\MysqlAdapter;
5 use Phinx\Migration\AbstractMigration;
6 
7 final class AddDeleteColumnsToEntitiesTables extends AbstractMigration {
11  public function change(): void {
12  $table = $this->table('entities');
13  if (!$table->hasColumn('deleted')) {
14  $table->addColumn('deleted', 'enum', [
15  'null' => false,
16  'default' => 'no',
17  'limit' => 3,
18  'values' => [
19  'yes',
20  'no',
21  ],
22  ]);
23 
24  $table->addIndex(['deleted'], [
25  'name' => 'deleted',
26  'unique' => false,
27  ]);
28  }
29 
30  if (!$table->hasColumn('time_deleted')) {
31  $table->addColumn('time_deleted', 'integer', [
32  'null' => false,
33  'default' => '0',
34  'limit' => MysqlAdapter::INT_REGULAR,
35  'precision' => 11,
36  ]);
37 
38  $table->addIndex(['time_deleted'], [
39  'name' => 'time_deleted',
40  'unique' => false,
41  ]);
42  }
43 
44  $table->update();
45  }
46 }
change()
Add the deleted and time_deleted columns to the entities table.
$table
Definition: database.php:52