I recently changed a date field to an integer field (the data was specified in number of months remaining rather than a date).
However all though the make migrations command works fine when I attempt to migrate this fails with a typecast error (note using postgres 9.5). Note there was only 1 instance/entry of the model, which I have also now deleted and the migrate still fails for some reason?
File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in executereturn self.cursor.execute(sql, params)
psycopg2.ProgrammingError: cannot cast type date to integer
LINE 1: ...end_date_fixed" TYPE integer USING "end_date_fixed"::integer^The above exception was the direct cause of the following exception:Traceback (most recent call last):File "manage.py", line 10, in <module>execute_from_command_line(sys.argv)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_lineutility.execute()File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in executeself.fetch_command(subcommand).run_from_argv(self.argv)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argvself.execute(*args, **cmd_options)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/core/management/base.py", line 399, in executeoutput = self.handle(*args, **options)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 200, in handleexecutor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/migrations/executor.py", line 92, in migrateself._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwardsstate = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/migrations/executor.py", line 198, in apply_migrationstate = migration.apply(state, schema_editor)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/migrations/migration.py", line 123, in applyoperation.database_forwards(self.app_label, schema_editor, old_state, project_state)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/migrations/operations/fields.py", line 201, in database_forwardsschema_editor.alter_field(from_model, from_field, to_field)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 482, in alter_fieldold_db_params, new_db_params, strict)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/backends/postgresql/schema.py", line 110, in _alter_fieldnew_db_params, strict,File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 634, in _alter_fieldparams,File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 110, in executecursor.execute(sql, params)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/backends/utils.py", line 79, in executereturn super(CursorDebugWrapper, self).execute(sql, params)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in executereturn self.cursor.execute(sql, params)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/utils.py", line 95, in __exit__six.reraise(dj_exc_type, dj_exc_value, traceback)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraiseraise value.with_traceback(tb)File "/Users/Yunti/.virtualenvs/switcher5/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in executereturn self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: cannot cast type date to integer
LINE 1: ...end_date_fixed" TYPE integer USING "end_date_fixed"::integer