diff options
author | Stefan Giehl <stefan@matomo.org> | 2022-02-03 00:38:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-03 00:38:31 +0300 |
commit | d4b430cb5c8b64711be10cdb6e5dffef7caacd97 (patch) | |
tree | d32af6b735ca4c713ff02178dc20787c84e57e8b /core/Updates | |
parent | 19cc16c4c0245bc47a3dd2c61d16843946a24c09 (diff) |
Make unique index compatible with database without long key support (#18723)
* Make unique index compatible with database without long key support
* Changed plugin_name to VARCHAR(60) and title index limit to 100
Diffstat (limited to 'core/Updates')
-rw-r--r-- | core/Updates/4.7.0-b2.php | 3 | ||||
-rw-r--r-- | core/Updates/4.7.1-b1.php | 57 |
2 files changed, 57 insertions, 3 deletions
diff --git a/core/Updates/4.7.0-b2.php b/core/Updates/4.7.0-b2.php index 3317067c8d..7d57ee147d 100644 --- a/core/Updates/4.7.0-b2.php +++ b/core/Updates/4.7.0-b2.php @@ -56,9 +56,6 @@ class Updates_4_7_0_b2 extends PiwikUpdates 'link' => 'VARCHAR(255) NULL', ), $primaryKey = 'idchange'); - - $migrations[] = $this->migration->db->addUniqueKey('changes', ['plugin_name', 'version', 'title'], 'unique_plugin_version_title'); - return $migrations; } diff --git a/core/Updates/4.7.1-b1.php b/core/Updates/4.7.1-b1.php new file mode 100644 index 0000000000..b543b812b0 --- /dev/null +++ b/core/Updates/4.7.1-b1.php @@ -0,0 +1,57 @@ +<?php + +/** + * Matomo - free/libre analytics platform + * + * @link https://matomo.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + */ + +namespace Piwik\Updates; + +use Piwik\Updater; +use Piwik\Updates as PiwikUpdates; +use Piwik\Updater\Migration; +use Piwik\Updater\Migration\Factory as MigrationFactory; + +/** + * Update for version 4.7.1-b1 + */ +class Updates_4_7_1_b1 extends PiwikUpdates +{ + /** + * @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. + * + * @param Updater $updater + * + * @return Migration[] + */ + public function getMigrations(Updater $updater) + { + $migrations = []; + + $migrations[] = $this->migration->db->changeColumn('changes', 'plugin_name', 'plugin_name', 'VARCHAR(60) NOT NULL'); + + $migrations[] = $this->migration->db->dropIndex('changes', 'unique_plugin_version_title'); + $migrations[] = $this->migration->db->addUniqueKey('changes', ['plugin_name', 'version', 'title(100)'], 'unique_plugin_version_title'); + + return $migrations; + } + + public function doUpdate(Updater $updater) + { + $updater->executeMigrations(__FILE__, $this->getMigrations($updater)); + } + +} |