Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Giehl <stefan@matomo.org>2022-07-25 03:37:45 +0300
committerGitHub <noreply@github.com>2022-07-25 03:37:45 +0300
commit06cf03738738164143dd117cfa2f55223603210c (patch)
tree61aaeef2f3f690b2afbf3e976828ecd285da8739
parentb031b18affe84914907c3b1a05cc9cf1c86086a6 (diff)
Adds unique index for user email (#19560)
-rw-r--r--core/Db/Schema/Mysql.php3
-rw-r--r--core/Updates/4.12.0-b2.php52
-rw-r--r--core/Version.php2
3 files changed, 55 insertions, 2 deletions
diff --git a/core/Db/Schema/Mysql.php b/core/Db/Schema/Mysql.php
index 1f8bc7d5f9..9ac76c951d 100644
--- a/core/Db/Schema/Mysql.php
+++ b/core/Db/Schema/Mysql.php
@@ -57,7 +57,8 @@ class Mysql implements SchemaInterface
invite_token VARCHAR(191) NULL,
invite_expired_at TIMESTAMP NULL,
invite_accept_at TIMESTAMP NULL,
- PRIMARY KEY(login)
+ PRIMARY KEY(login),
+ UNIQUE INDEX `uniq_email` (`email`)
) ENGINE=$engine DEFAULT CHARSET=$charset
",
'user_token_auth' => "CREATE TABLE {$prefixTables}user_token_auth (
diff --git a/core/Updates/4.12.0-b2.php b/core/Updates/4.12.0-b2.php
new file mode 100644
index 0000000000..829b22ef10
--- /dev/null
+++ b/core/Updates/4.12.0-b2.php
@@ -0,0 +1,52 @@
+<?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.12.0-b2
+ */
+class Updates_4_12_0_b2 extends PiwikUpdates
+{
+ /**
+ * @var MigrationFactory
+ */
+ private $migration;
+
+ public function __construct(MigrationFactory $factory)
+ {
+ $this->migration = $factory;
+ }
+
+ /**
+ * @param Updater $updater
+ *
+ * @return Migration[]
+ */
+ public function getMigrations(Updater $updater)
+ {
+ $uniqueIndex = $this->migration->db->addUniqueKey('user', 'email', 'uniq_email');
+
+ // if for some reason a duplicate email exists we simply ignore the error and don't add the index.
+ $uniqueIndex->addErrorCodeToIgnore(Migration\Db::ERROR_CODE_DUPLICATE_ENTRY);
+
+ return [$uniqueIndex];
+ }
+
+ public function doUpdate(Updater $updater)
+ {
+ $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
+ }
+}
diff --git a/core/Version.php b/core/Version.php
index 9a5e30e677..1c774e811c 100644
--- a/core/Version.php
+++ b/core/Version.php
@@ -21,7 +21,7 @@ final class Version
* The current Matomo version.
* @var string
*/
- const VERSION = '4.12.0-b1';
+ const VERSION = '4.12.0-b2';
const MAJOR_VERSION = 4;