From f37cea1cade8826c02e8b0a2ff6c23a61dfbbca5 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Tue, 20 Sep 2022 11:13:24 +0200 Subject: [PATCH] fix: [migration:unique_usernames] Table 'users' is specified twice, both as a target and as a separate source --- config/Migrations/20220918000001_unique_usernames.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/Migrations/20220918000001_unique_usernames.php b/config/Migrations/20220918000001_unique_usernames.php index ce41c1c..41ec565 100644 --- a/config/Migrations/20220918000001_unique_usernames.php +++ b/config/Migrations/20220918000001_unique_usernames.php @@ -20,7 +20,7 @@ final class UniqueUserNames extends AbstractMigration { $table = $this->table('users'); $exists = $table->hasIndexByName('users', 'username'); - $this->execute('DELETE FROM users WHERE id NOT IN (SELECT MIN(id) FROM users GROUP BY LOWER(username));'); + $this->execute('DELETE FROM users WHERE id NOT IN (SELECT MIN(id) FROM (select * from users) AS u2 GROUP BY LOWER(u2.username));'); if (!$exists) { $table->addIndex( [