Model Migration Error

Hi Guys, Can you please help i've just tried to run a pull request from bitbucket, there was changes that needed to be stashed which i did then ran a pull request again.

After it had done it's thing i then received this error:

"CommandError: Conflicting migrations detected; multiple leaf nodes in the migration graph: (0002_auto_20180617_0045, 0003_auto_20180709_1952 in dsblog).
To fix them run 'python makemigrations --merge'
(myvenv) 06:08 ~/dsblog/blogbase (master)$ python3 makemigrations --merge"

Which i ran the merge which created the 004 migration file.

Then when i went to run makemigrations and migrate again it gave me this error:

"Applying dsblog.0002_auto_20180709_1914...Traceback (most recent call last):
  File "", line 22, in <module>
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/core/management/", line 364, in execute_from_command_line
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/core/management/", line 356, in execute
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/core/management/", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/core/management/", line 330, in execute
    output = self.handle(*args, **options)
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/core/management/commands/", line 204, in handle
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/db/migrations/", line 115, in migrate
    state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/db/migrations/", line 145, in _migrate_all_forwards
    state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/db/migrations/", line 244, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/db/migrations/", line 119, in apply
    operation.state_forwards(self.app_label, project_state)
  File "/home/mgcheetham/dsblog/blogbase/myvenv/lib/python3.5/site-packages/django/db/migrations/operations/", line 143, in state_forwards
    for name, instance in state.models[app_label, self.model_name_lower].fields:
KeyError: ('dsblog', 'comment'"

Which it's trying to apply the 002 migration which isn't correct, it needs to be 003.

However i now can't seem to either stop it from migrating the 002, or pull down and overwrite the 003 and make it apply it without getting the error.

Can you help as i can't find any help or troubleshooting information about migrations.

Is there a way i can stop it from looking at 002 or revert the changes?


[edited by admin: formatting]

is this in production? if so- oh dear, sounds like you need to hire someone to read through your migrations/current db table configurations and sort it out.

if not- you know you could just delete all the migrations and database etc and start from an initial migration again right? :D