From dfb7bddf652d396c99c9b5c5d4d740b3c910590d Mon Sep 17 00:00:00 2001 From: Amit Phulera Date: Tue, 22 Oct 2024 13:08:36 +0530 Subject: [PATCH] skip on fresh install on fresh install we were getting error that django.utils.connection.ConnectionDoesNotExist: The connection 'commcarehq_repeaters' doesn't exist. It makes sense, the things that migration was doing were related to repeat records couch to sql migration. And we don't need to run it on fresh installs --- corehq/motech/repeaters/migrations/0002_repeaters_db.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/corehq/motech/repeaters/migrations/0002_repeaters_db.py b/corehq/motech/repeaters/migrations/0002_repeaters_db.py index b2147c2bb0ab..e76e410f382c 100644 --- a/corehq/motech/repeaters/migrations/0002_repeaters_db.py +++ b/corehq/motech/repeaters/migrations/0002_repeaters_db.py @@ -7,6 +7,8 @@ from django.db import connections, migrations from django.db.utils import DEFAULT_DB_ALIAS +from corehq.util.django_migrations import skip_on_fresh_install + # Use a separate user for the fdw connection because postgres_fdw # changes session settings like search_path that interfere with other # clients because of pg_bouncer connection pooling. @@ -120,12 +122,14 @@ class RepeatersMigration(migrations.RunSQL): + @skip_on_fresh_install def database_forwards(self, app_label, schema_editor, from_state, to_state): if self.should_apply(schema_editor): assert count_records(schema_editor.connection, "repeatrecord") == 0 assert count_records(schema_editor.connection, "repeatrecordattempt") == 0 self._run_sql(schema_editor, self.sql.format(**self.context)) + @skip_on_fresh_install def database_backwards(self, app_label, schema_editor, from_state, to_state): if self.should_apply(schema_editor): assert count_records(connections["repeaters"], "repeatrecord") == 0