diff --git a/cmd/setup/39.sql b/cmd/setup/39.sql index 4abc815c25..2abb701c9f 100644 --- a/cmd/setup/39.sql +++ b/cmd/setup/39.sql @@ -1,6 +1,8 @@ DELETE FROM eventstore.fields WHERE aggregate_type = 'org' -AND aggregate_id NOT IN ( - SELECT id - FROM projections.orgs1 +AND aggregate_id IN ( + SELECT aggregate_id + FROM eventstore.events2 + WHERE aggregate_type = 'org' + AND event_type = 'org.removed' );