mbari-org / SeafloorMappingDB

Make MBARI seafloor mapping datasets more accessible and useful
GNU General Public License v3.0
3 stars 6 forks source link

Catch ProgrammingError from ChoiceFilter() during inital migrate command #246

Closed MBARIMike closed 5 months ago

MBARIMike commented 5 months ago

This solves the problem seen when creating a new database from scratch following the README.md instructions:

django        |   File "/app/smdb/config/urls.py", line 12, in <module>
django        |     from smdb.views import (
django        |   File "/app/smdb/smdb/views.py", line 22, in <module>
django        |     from smdb.filters import CompilationFilter, ExpeditionFilter, MissionFilter
django        |   File "/app/smdb/smdb/filters.py", line 13, in <module>
django        |     class MissionFilter(FilterSet):
django        |   File "/app/smdb/smdb/filters.py", line 22, in MissionFilter
django        |     choices=[
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 398, in __iter__
django        |     self._fetch_all()
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 1881, in _fetch_all
django        |     self._result_cache = list(self._iterable_class(self))
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/models/query.py", line 285, in __iter__
django        |     for row in compiler.results_iter(
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/models/sql/compiler.py", line 1513, in results_iter
django        |     results = self.execute_sql(
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/models/sql/compiler.py", line 1562, in execute_sql
django        |     cursor.execute(sql, params)
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 102, in execute
django        |     return super().execute(sql, params)
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 67, in execute
django        |     return self._execute_with_wrappers(
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
django        |     return executor(sql, params, many, context)
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 84, in _execute
django        |     with self.db.wrap_database_errors:
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/utils.py", line 91, in __exit__
django        |     raise dj_exc_value.with_traceback(traceback) from exc_value
django        |   File "/usr/local/lib/python3.10/dist-packages/django/db/backends/utils.py", line 89, in _execute
django        |     return self.cursor.execute(sql, params)
django        | django.db.utils.ProgrammingError: relation "smdb_mission" does not exist
django        | LINE 1: SELECT DISTINCT "smdb_mission"."region_name" FROM "smdb_miss...