[MM-52288] Oauth2 postgres migration issue (#23036)
* fixing migrations that caused some oauth2 issues
Этот коммит содержится в:
@@ -214,6 +214,8 @@ channels/db/migrations/mysql/000106_fileinfo_channelid.down.sql
|
|||||||
channels/db/migrations/mysql/000106_fileinfo_channelid.up.sql
|
channels/db/migrations/mysql/000106_fileinfo_channelid.up.sql
|
||||||
channels/db/migrations/mysql/000107_threadmemberships_cleanup.down.sql
|
channels/db/migrations/mysql/000107_threadmemberships_cleanup.down.sql
|
||||||
channels/db/migrations/mysql/000107_threadmemberships_cleanup.up.sql
|
channels/db/migrations/mysql/000107_threadmemberships_cleanup.up.sql
|
||||||
|
channels/db/migrations/mysql/000108_remove_orphaned_oauth_preferences.down.sql
|
||||||
|
channels/db/migrations/mysql/000108_remove_orphaned_oauth_preferences.up.sql
|
||||||
channels/db/migrations/postgres/000001_create_teams.down.sql
|
channels/db/migrations/postgres/000001_create_teams.down.sql
|
||||||
channels/db/migrations/postgres/000001_create_teams.up.sql
|
channels/db/migrations/postgres/000001_create_teams.up.sql
|
||||||
channels/db/migrations/postgres/000002_create_team_members.down.sql
|
channels/db/migrations/postgres/000002_create_team_members.down.sql
|
||||||
@@ -428,3 +430,5 @@ channels/db/migrations/postgres/000106_fileinfo_channelid.down.sql
|
|||||||
channels/db/migrations/postgres/000106_fileinfo_channelid.up.sql
|
channels/db/migrations/postgres/000106_fileinfo_channelid.up.sql
|
||||||
channels/db/migrations/postgres/000107_threadmemberships_cleanup.down.sql
|
channels/db/migrations/postgres/000107_threadmemberships_cleanup.down.sql
|
||||||
channels/db/migrations/postgres/000107_threadmemberships_cleanup.up.sql
|
channels/db/migrations/postgres/000107_threadmemberships_cleanup.up.sql
|
||||||
|
channels/db/migrations/postgres/000108_remove_orphaned_oauth_preferences.down.sql
|
||||||
|
channels/db/migrations/postgres/000108_remove_orphaned_oauth_preferences.up.sql
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
-- Migration only applied to postgres
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-- Migration only applied to postgres
|
||||||
@@ -4,8 +4,7 @@ WITH oauthDelete AS (
|
|||||||
DELETE FROM oauthaccessdata o
|
DELETE FROM oauthaccessdata o
|
||||||
WHERE NOT EXISTS (
|
WHERE NOT EXISTS (
|
||||||
SELECT p.* FROM preferences p
|
SELECT p.* FROM preferences p
|
||||||
WHERE o.clientid = p.name AND o.userid = p.userid AND p.category = 'oauth_app'
|
WHERE o.clientid = p.name AND o.userid = p.userid AND p.category = 'oauth_app'
|
||||||
and p.name IS NULL
|
|
||||||
)
|
)
|
||||||
RETURNING o.token
|
RETURNING o.token
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
-- Skipping it because the forward migrations are destructive
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
DO $$
|
||||||
|
DECLARE
|
||||||
|
preferences_exist boolean := false;
|
||||||
|
BEGIN
|
||||||
|
SELECT count(p.*) != 0 INTO preferences_exist FROM preferences p
|
||||||
|
WHERE (
|
||||||
|
(NOT EXISTS (
|
||||||
|
SELECT o.* FROM oauthaccessdata o
|
||||||
|
WHERE o.clientid = p.name AND o.userid = p.userid AND p.category = 'oauth_app'
|
||||||
|
))
|
||||||
|
AND
|
||||||
|
(NOT EXISTS (
|
||||||
|
SELECT oa.* FROM oauthauthdata oa
|
||||||
|
WHERE oa.clientid = p.name AND oa.userid = p.userid AND p.category = 'oauth_app'
|
||||||
|
))
|
||||||
|
)
|
||||||
|
AND p.category = 'oauth_app';
|
||||||
|
IF preferences_exist THEN
|
||||||
|
DELETE FROM preferences p
|
||||||
|
WHERE (
|
||||||
|
(NOT EXISTS (
|
||||||
|
SELECT o.* FROM oauthaccessdata o
|
||||||
|
WHERE o.clientid = p.name AND o.userid = p.userid AND p.category = 'oauth_app'
|
||||||
|
))
|
||||||
|
AND
|
||||||
|
(NOT EXISTS (
|
||||||
|
SELECT oa.* FROM oauthauthdata oa
|
||||||
|
WHERE oa.clientid = p.name AND oa.userid = p.userid AND p.category = 'oauth_app'
|
||||||
|
))
|
||||||
|
)
|
||||||
|
AND p.category = 'oauth_app';
|
||||||
|
END IF;
|
||||||
|
END $$;
|
||||||
Ссылка в новой задаче
Block a user