From 8009c53332a1fd0946fac54898e35fbc4fe4e5ad Mon Sep 17 00:00:00 2001 From: sgiehl Date: Sun, 30 Oct 2016 21:03:22 +0100 Subject: Migrate Goal plugin update script to use Migration Factory --- plugins/Goals/Updates/3.0.0-b1.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/plugins/Goals/Updates/3.0.0-b1.php b/plugins/Goals/Updates/3.0.0-b1.php index db28c5a45c..923c2acb7a 100644 --- a/plugins/Goals/Updates/3.0.0-b1.php +++ b/plugins/Goals/Updates/3.0.0-b1.php @@ -12,21 +12,38 @@ namespace Piwik\Plugins\Goals; use Piwik\Common; use Piwik\Updater; use Piwik\Updates; +use Piwik\Updater\Migration\Factory as MigrationFactory; class Updates_3_0_0_b1 extends Updates { - public function getMigrationQueries(Updater $updater) + /** + * @var MigrationFactory + */ + private $migration; + + public function __construct(MigrationFactory $factory) + { + $this->migration = $factory; + } + + /** + * Here you can define one or multiple SQL statements that should be executed during the update. + * @return Updater\Migration[] + */ + public function getMigrations(Updater $updater) { - $updateSql = array( - 'ALTER TABLE `' . Common::prefixTable('goal') - . '` ADD COLUMN `description` VARCHAR(255) NOT NULL DEFAULT \'\' AFTER `name`;' => array(1060) + return array( + $this->migration->db->addColumn('goal', 'description', 'VARCHAR(255) NOT NULL DEFAULT \'\'', 'name'), ); - return $updateSql; } + /** + * Here you can define any action that should be performed during the update. For instance executing SQL statements, + * renaming config entries, updating files, etc. + */ public function doUpdate(Updater $updater) { - $updater->executeMigrationQueries(__FILE__, $this->getMigrationQueries($updater)); + $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); } } -- cgit v1.2.3