Clean child sessions in iam membership migration

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-01-19 20:52:48 +04:00
parent 9e01830a34
commit df23bc144b

View File

@@ -50,13 +50,24 @@ updated_profiles AS (
old_to_new m old_to_new m
WHERE WHERE
mp.membership_id = m.old_id RETURNING id mp.membership_id = m.old_id RETURNING id
),
deleted_memberships AS (
DELETE FROM
iam_memberships
WHERE
id IN (
SELECT
old_id
FROM
old_to_new
) RETURNING id
) )
DELETE FROM DELETE FROM
iam_memberships iam_sessions
WHERE WHERE
id IN ( membership_id IN (
SELECT SELECT
old_id old_id
FROM FROM
old_to_new old_to_new
) RETURNING id; );