This is going to be fun…
Installed a Python 3 virtualenv in dev.openrem.org folder,
pip install -e source etc, added in
local_settings.pyhas to be manually updated
attempted database migration:
File "/home/user/sites/dev.openrem.org/virtualenv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute ('accumulated_xray_dose', models.ForeignKey(to='remapp.AccumXRayDose')), TypeError: __init__() missing 1 required positional argument: 'on_delete'
This relates to change in Django 2.0 requiring explicit argument on
ForeignKeyas to behaviour
on_delete. All the models are updated, but the existing migration files are not. I’d usually propose wiping away all the migration files and creating a fresh fake initial, but that only works if the database and the models match (you do this, then upgrade and migrate the database).
- This doesn’t really work when you are changing from Django 1.8, with the old models and Django 2.2 with the new ones.
Started by adding
on_deleteargument to the initial migration file, expecting to need to do it to lots of lines. Did the first one it complained about, then it was happy till:
File "/home/user/sites/dev.openrem.org/source/openrem/remapp/migrations/0012_objectuidsprocessed.py", line 19, in Migration ('general_study_module_attributes', models.ForeignKey(to='remapp.GeneralStudyModuleAttr')), TypeError: __init__() missing 1 required positional argument: 'on_delete'
Updated that line in the same way, then:
File "/home/deploy/sites/dev.openrem.org/source/openrem/remapp/migrations/0009_update_median_function.py", line 6, in <module> from django.db.models.loading import get_model ModuleNotFoundError: No module named 'django.db.models.loading'
But that module is not used, so removed the line, tried again:
File "/home/user/sites/dev.openrem.org/source/openrem/remapp/migrations/0005_auto_20171013_2149.py", line 29, in Migration field=models.ForeignKey(related_name='ssde_wed_method', blank=True, to='remapp.ContextID', null=True), TypeError: __init__() missing 1 required positional argument: 'on_delete'
Fixed that, tried again. Now it is going back to
ForeignKeymissing positional arguments.
And so on. I’ll carry on going through in the morning, but suffice to say we need to rehearse this and work out a plan that can work for everyone.
It might be that we need an ‘upgrade’ release with Django 2.2 but the same models as release 0.10. We can then generate a fresh
initial migration file and then upgrade again to the full release with the model changes which will now be happy…
(Updated description because formatting got messed up…)