Django Log - column does not exist

Hi All,

"column repeaters_repeater.id_ does not exist" message is appearing in django log file.

Your help please.

Thank you,

2023-11-02 10:04:11,996 ERROR [notify] Notify Exception: create_repeat_records had an error resulting in a retry
Traceback (most recent call last):
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedColumn: column repeaters_repeater.id_ does not exist
LINE 1: SELECT "repeaters_repeater"."repeater_type", "repeaters_repe...
                                                     ^
HINT:  Perhaps you meant to reference the column "repeaters_repeater.id".


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/corehq/motech/repeaters/signals.py", line 53, in create_repeat_records
    _create_repeat_records(repeater_cls, payload)
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/corehq/motech/repeaters/signals.py", line 76, in _create_repeat_records
    repeaters = repeater_cls.objects.by_domain(domain)
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/corehq/motech/repeaters/models.py", line 252, in by_domain
    return list(self.filter(domain=domain))
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/models/query.py", line 262, in __len__
    self._fetch_all()
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/models/query.py", line 1324, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/models/query.py", line 51, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1175, in execute_sql
    cursor.execute(sql, params)
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/sentry_sdk/integrations/django/__init__.py", line 582, in execute
    return real_execute(self, sql, params)
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/cchq/www/echis/releases/2023-11-01_19.41/python_env-3.9/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column repeaters_repeater.id_ does not exist
LINE 1: SELECT "repeaters_repeater"."repeater_type", "repeaters_repe...

Hi Siraj,

The error is pointing to a column "id_" missing.
Are you running this on a local environment? I suspect if there is some code change that accidentally changed a variable name.

Yes, it is running on local servers.

Hi @sirajhassan

I assume you meant local machine for development.
Please check for any changes that you would have made that could result in the error you are getting.