From ce839a5d5c4f82d5d97eed5fcd6d0747d8d3e316 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Sat, 27 Jul 2019 16:50:54 +0100 Subject: [PATCH] FIX: Ignore duplicate user_ids when migrating old data The old storage mechanism had no unique index on the user_id, so it is possible to have bad data. In this case, take the first value, and ignore the rest. --- db/migrate/20190724055909_move_to_managed_authenticator.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/db/migrate/20190724055909_move_to_managed_authenticator.rb b/db/migrate/20190724055909_move_to_managed_authenticator.rb index 8db23ca..5ee2735 100644 --- a/db/migrate/20190724055909_move_to_managed_authenticator.rb +++ b/db/migrate/20190724055909_move_to_managed_authenticator.rb @@ -15,6 +15,8 @@ class MoveToManagedAuthenticator < ActiveRecord::Migration[5.2] CURRENT_TIMESTAMP FROM plugin_store_rows WHERE plugin_name = 'oauth2_basic' + ON CONFLICT (provider_name, user_id) + DO NOTHING SQL end end