Elgg  Version master
20221110111653_add_river_last_action.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
4 use Phinx\Migration\AbstractMigration;
5 use Phinx\Db\Adapter\MysqlAdapter;
6 
7 final class AddRiverLastAction extends AbstractMigration {
11  public function change(): void {
12  $table = $this->table('river');
13  if ($table->hasColumn('last_action')) {
14  return;
15  }
16 
17  $table->addColumn('last_action', 'integer', [
18  'null' => false,
19  'limit' => MysqlAdapter::INT_REGULAR,
20  'precision' => 11,
21  ]);
22  $table->addIndex(['last_action'], [
23  'name' => 'last_action',
24  'unique' => false,
25  ]);
26 
27  $table->update();
28 
29  // copy posted into last_action
30  $prefix = $this->getAdapter()->getOption('table_prefix');
31 
32  $this->execute("UPDATE {$prefix}river SET last_action = posted");
33  }
34 }
$table
Definition: user.php:37
change()
Adds the river last action column and fills it with the posted timestamp.