Data type mismatch when running database migrations
See original GitHub issueWhen running python manage.py makemigrations
followed by python manage.py migrate
, I get this error: django.db.utils.IntegrityError: datatype mismatch
. I cloned a fresh copy and still get the error. This is the exact sequence I did if anyone wants to reproduce it. Anyone know why this is happening, or if it’s a problem just on my end?
git clone git@github.com:phageParser/phageParser.git phageParsertest
cd phageParsertest/phageAPI
git checkout django-dev
python manage.py makemigrations
python manage.py migrate # this is where the error happens
This is the full error message:
Applying restapi.0002_auto_20170413_1317...Traceback (most recent call last):
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
sqlite3.IntegrityError: datatype mismatch
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/migrations/operations/fields.py", line 204, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 495, in alter_field
old_db_params, new_db_params, strict)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/sqlite3/schema.py", line 255, in _alter_field
self._remake_table(model, alter_fields=[(old_field, new_field)])
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/sqlite3/schema.py", line 199, in _remake_table
self.quote_name(model._meta.db_table),
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 112, in execute
cursor.execute(sql, params)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/madeleine/anaconda2/envs/django/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: datatype mismatch
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Troubleshoot data mismatch issues between the source and ...
I have an AWS Database Migration Service (AWS DMS) task that is in the full-load complete or replication ongoing stage of migration.
Read more >"SQLite Error 20: 'datatype mismatch'.'" error while peforming ...
Compile and run Test console application - context.Database.Migrate(); throws an exception. Exception StackTrace: at Microsoft.Data.Sqlite.
Read more >Setting up Data type definitions for mismatch in ... - SAP Blogs
You need to run your query in ISQL to extract the content to be exported to another database. After successful completion of the...
Read more >I get a message about data type mismatch - Microsoft Support
You get a "Data Type Mismatch" error when you run a query. See some reasons why and how to fix this.
Read more >Error when i try to run migrate for my model - Google Groups
When i run migrate i encouter datatype mismatch error. ... /python3.5/site-packages/django/db/migrations/executor.py", line 117, in migrate.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@mbonsma I think the problem arises since the models file has been changed and not been migrated to the old database. I would suggest resetting the database first and then migrating. According to this, resetting can be done by running
python manage.py flush
It works for me! but I have to run
python manage.py createsuperuser
to create a superuser again.