populate_db: Clean up existing RemoteRealm, RemoteZulipServer objects.

As of c9b0602320 and
8b55d60f9e we create a default
registration for the dev env "RemoteZulipServer" (and also RemoteRealms
for the dev realms) in populate_db. However these models weren't listed
in clear_database, meaning the state wasn't properly cleaned up at the
start of the command.

Most important, this would manifest in getting:
```
django.db.utils.IntegrityError: duplicate key value violates unique
constraint "zilencer_remotezulipserver_uuid_key"
DETAIL:  Key (uuid)=(......) already exists
```

if you re-run populate_db.
This commit is contained in:
Mateusz Mandera
2023-12-06 18:20:31 +01:00
committed by Tim Abbott
parent 578f9fb77e
commit 24d6ae83c2

View File

@@ -73,7 +73,7 @@ from zerver.models import (
get_user_by_delivery_email,
get_user_profile_by_id,
)
from zilencer.models import RemoteZulipServer
from zilencer.models import RemoteRealm, RemoteZulipServer
from zilencer.views import update_remote_realm_data_for_server
settings.USING_TORNADO = False
@@ -128,6 +128,8 @@ def clear_database() -> None:
UserMessage,
Client,
DefaultStream,
RemoteRealm,
RemoteZulipServer,
]:
model.objects.all().delete()
Session.objects.all().delete()