Migrations broken on empty DB
For the AlekSIS 2023.6 distribution, which includes Alsijil ~3.0, aleksis-admin migrate
fails with the following error:
Applying alsijil.0005_groups_of_person...Traceback (most recent call last):
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/query.py", line 1846, in transform
return self.try_transform(wrapped, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/query.py", line 1356, in try_transform
raise FieldError(
django.core.exceptions.FieldError: Unsupported lookup 'date_start' for BigAutoField or join on the field not permitted.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/aleksis-admin", line 8, in <module>
sys.exit(aleksis_cmd())
^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/aleksis/core/__main__.py", line 14, in aleksis_cmd
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.11/dist-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.11/dist-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.11/dist-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.11/dist-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/migration.py", line 132, in apply
operation.database_forwards(
File "/usr/local/lib/python3.11/dist-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
self.code(from_state.apps, schema_editor)
File "/usr/local/lib/python3.11/dist-packages/aleksis/apps/alsijil/migrations/0005_groups_of_person.py", line 11, in add_groups
for personal_note in PersonalNote.objects.using(db_alias).all():
File "/usr/local/lib/python3.11/dist-packages/django/db/models/query.py", line 398, in __iter__
self._fetch_all()
File "/usr/local/lib/python3.11/dist-packages/django/db/models/query.py", line 1881, in _fetch_all
self._result_cache = list(self._iterable_class(self))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/query.py", line 91, in __iter__
results = compiler.execute_sql(
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/cachalot/monkey_patch.py", line 37, in inner
return original(compiler, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/cachalot/monkey_patch.py", line 91, in inner
cache_key = cachalot_settings.CACHALOT_QUERY_KEYGEN(compiler)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/cachalot/utils.py", line 100, in get_query_cache_key
sql, params = compiler.as_sql()
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/compiler.py", line 736, in as_sql
extra_select, order_by, group_by = self.pre_sql_setup(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/compiler.py", line 85, in pre_sql_setup
order_by = self.get_order_by()
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/compiler.py", line 459, in get_order_by
for expr, is_ref in self._order_by_pairs():
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/compiler.py", line 442, in _order_by_pairs
yield from self.find_ordering_name(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/compiler.py", line 1086, in find_ordering_name
return [
^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/compiler.py", line 1087, in <listcomp>
(OrderBy(transform_function(t, alias), descending=descending), False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/query.py", line 1850, in transform
raise last_field_exception
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/query.py", line 1823, in setup_joins
path, final_field, targets, rest = self.names_to_path(
^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/django/db/models/sql/query.py", line 1724, in names_to_path
raise FieldError(
django.core.exceptions.FieldError: Cannot resolve keyword 'date_start' into field. Choices are: exams, extended_data, groups, id, lesson_periods, periods, site, site_id, subject, subject_id, teachers, validity, validity_id
Edited by magicfelix