Skip to content

Commit

Permalink
skip on fresh install
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AmitPhulera committed Oct 22, 2024
1 parent f089399 commit dfb7bdd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions corehq/motech/repeaters/migrations/0002_repeaters_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dfb7bdd

Please sign in to comment.