diff options
author | sgiehl <stefan@piwik.org> | 2016-10-30 23:03:22 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2016-10-30 23:22:45 +0300 |
commit | 8009c53332a1fd0946fac54898e35fbc4fe4e5ad (patch) | |
tree | 920f64d24e46f78ab644d1cfb7c0e9085639c863 | |
parent | 646abeac68ebd6c4d20774ca900164fc4332108b (diff) |
Migrate Goal plugin update script to use Migration Factory
-rw-r--r-- | plugins/Goals/Updates/3.0.0-b1.php | 29 |
1 files 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)); } } |