Merge pull request #59 from MrPetovan/bug/38-unique-server-alias

Add unique key on server_alias.alias
This commit is contained in:
Michael Vogel 2020-09-27 00:28:19 +02:00 committed by GitHub
commit 7780d3af09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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;