The operation is reversible (apart from any data loss, which of course is irreversible) if the field is nullable or if it has a default value that can be used to populate the recreated column. If the field is not nullable and does not have a default value, the operation is irreversible.
I imagine retrospectively adding a migration between 0001 and 0002 (to add default='') would have prevented this issue, but it is a bit too late to do so.
The only way, in my opinion, is to add the default='' to the original definition - which shouldn't impact anyone already using django-cities.
Checklist
master
branch of django-cities.Steps to reproduce
Expected behavior
No errors
Actual behavior
psycopg2.IntegrityError: column "continent_code" contains null values
Full output (including Traceback): https://gist.github.com/leibowitz/0427c3e70ffb07d81e1ecf82b349cf00
This is due to the last
RemoveField
of the 0002_continent_models_and_foreign_keys.py migrationAs the documentation mentions:
Source: https://docs.djangoproject.com/en/2.0/ref/migration-operations/#removefield
Adding
default=''
to theCountry.continent
field definition https://github.com/coderholic/django-cities/blob/422e92d9ceaa07444d8fd6de00a526c72bf8e9ca/cities/migrations/0001_initial.py#L64 solves the issue.I imagine retrospectively adding a migration between 0001 and 0002 (to add
default=''
) would have prevented this issue, but it is a bit too late to do so.The only way, in my opinion, is to add the
default=''
to the original definition - which shouldn't impact anyone already usingdjango-cities
.https://github.com/coderholic/django-cities/pull/199