diff --git a/common/src/main/resources/migrations/loginLog/002_add_network.sql b/common/src/main/resources/migrations/loginLog/002_add_network.sql index fa8c100..64f61c6 100644 --- a/common/src/main/resources/migrations/loginLog/002_add_network.sql +++ b/common/src/main/resources/migrations/loginLog/002_add_network.sql @@ -1,6 +1,6 @@ -- Connection key per attempt: the IPv4 address or the IPv6 /64 prefix. Groups accounts by internet connection. ALTER TABLE login_attempts - ADD COLUMN network VARCHAR(45) NULL COMMENT 'IPv4 address or IPv6 /64 prefix, NULL if unknown' AFTER ip, - ADD KEY idx_network_at (network, at); + ADD COLUMN IF NOT EXISTS network VARCHAR(45) NULL COMMENT 'IPv4 address or IPv6 /64 prefix, NULL if unknown' AFTER ip, + ADD KEY IF NOT EXISTS idx_network_at (network, at); UPDATE login_attempts SET network = ip WHERE ip REGEXP '^[0-9]{1,3}([.][0-9]{1,3}){3}$';