Skip to content

Commit

Permalink
[Cherry-Pick] Ensure migration 55 doesn't fail if there's deleted use…
Browse files Browse the repository at this point in the history
…rs (#2626) (#2637)
  • Loading branch information
peb-adr authored Sep 23, 2024
1 parent 4e06431 commit 8750005
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datastore.shared.util import fqid_from_collection_and_id
from datastore.writer.core import BaseRequestEvent, RequestUpdateEvent

from ...shared.filters import FilterOperator
from ...shared.filters import And, FilterOperator


class Migration(BaseModelMigration):
Expand All @@ -15,7 +15,10 @@ class Migration(BaseModelMigration):
def migrate_models(self) -> list[BaseRequestEvent] | None:
users = self.reader.filter(
"user",
FilterOperator("is_active", "=", None),
And(
FilterOperator("is_active", "=", None),
FilterOperator("meta_deleted", "!=", True),
),
[],
)
events: list[BaseRequestEvent] = [
Expand Down
6 changes: 6 additions & 0 deletions tests/system/migrations/test_0055_is_active_true_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ def test_migration(write, finalize, assert_model):
"fqid": "user/4",
"fields": {"id": 4, "is_active": None},
},
{
"type": "create",
"fqid": "user/5",
"fields": {"id": 5},
},
)
write({"type": "delete", "fqid": "user/5", "fields": {}})

finalize("0055_is_active_true_default")

Expand Down

0 comments on commit 8750005

Please sign in to comment.