[ * 'FirstMethodName', * 'SecondMethodName', * ], * * The method names specified should exist within this class, as this class * is specifically designed for handling schema migrations. Each method is * responsible for tasks such as altering table structures, adding or removing * columns, changing column types, or other schema-level changes to the database. * * Note: This class is not intended for data migrations such as transferring * data between tables, modifying data values, or other operations on the * contents of the database. Those operations should be handled by a dedicated * data migration class. * * @var array */ protected $migrationSteps = [ '14.12.6' => [ 'addFirstAndLastPageToVisitors', ], // '14.13.5' => [ // 'dropDuplicateColumnsFromUserOnline' // ] ]; /** * Adds 4 new columns to the 'visitors' table: 'first_page', 'first_view', 'last_page', and 'last_view'. * * @return void */ public function addFirstAndLastPageToVisitors() { $this->ensureConnection(); try { DatabaseFactory::table('update') ->setName('visitor') ->setArgs([ 'add' => [ 'first_page' => 'bigint(20) UNSIGNED DEFAULT NULL', 'first_view' => 'datetime DEFAULT NULL', 'last_page' => 'bigint(20) UNSIGNED DEFAULT NULL', 'last_view' => 'datetime DEFAULT NULL' ] ]) ->execute(); } catch (Exception $e) { $this->setErrorStatus($e->getMessage()); } } /** * Removes duplicate columns from the 'user_online' table. * * @return void */ public function dropDuplicateColumnsFromUserOnline() { try { DatabaseFactory::table('update') ->setName('useronline') ->setArgs([ 'drop' => [ 'referred', 'agent', 'platform', 'version', 'user_id', 'page_id', 'type', 'location', 'city', 'region', 'continent' ] ]) ->execute(); } catch (Exception $e) { $this->setErrorStatus($e->getMessage()); } } }