Add unique key on server_alias.alias #59

Merged
MrPetovan merged 2 commits from bug/38-unique-server-alias into stable 2020-09-27 00:28:20 +02:00
3 changed files with 9 additions and 1 deletions

View file

@ -33,7 +33,9 @@ class Server extends \Friendica\Directory\Model
SET `server_id` = :server_id, SET `server_id` = :server_id,
`alias` = :alias, `alias` = :alias,
`timestamp` = NOW() `timestamp` = NOW()
ON DUPLICATE KEY UPDATE `timestamp` = NOW()', ON DUPLICATE KEY UPDATE
`server_id` = :server_id,
`timestamp` = NOW()',
[ [
'server_id' => $server_id, 'server_id' => $server_id,
'alias' => strtolower($server_alias) 'alias' => strtolower($server_alias)

View file

View file

@ -0,0 +1,6 @@
BEGIN;
CREATE TABLE temp_server_alias AS SELECT * FROM server_alias GROUP BY alias;
DROP TABLE server_alias;
RENAME TABLE temp_server_alias TO server_alias;
CREATE UNIQUE INDEX server_alias_alias_uindex ON server_alias (alias);
COMMIT;