﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
25922	migrate --fake-initial fails to handle ManyToManyFields created by AddField	tkhyn	Tim Graham	"Hello,

I've run into an issue with Django 1.9's new {{{migrate --run-syncdb}}} command, which is supposed to replace {{{syncdb}}}. It does not seem to be related to #25884.

Basically, the workflow syncdb => makemigrations => migrate --fake-initial is broken when ManyToManyFields are used in models. Using any other field (even FKs) work fine.

I found out that when running {{{migrate --fake-initial}}}, {{{MigrationExecutor.detect_soft_applied}}} could not find a matching column for the M2M field in the existing table, and therefore considers that the initial migration has not been implicitly applied. My understanding is that {{{migrate --run-syncdb}}} failed to create that in the first place.

I have set up a minimal project to expose the issue: 

- [https://bitbucket.org/tkhyn/dj19_run_syncdb/src/default not working with Django 1.9]
- [https://bitbucket.org/tkhyn/dj19_run_syncdb/src/dj18 working like a charm with Django 1.8]

My use case ? [https://bitbucket.org/tkhyn/django-gm2m django-gm2m]'s test suite needs to initialize individual apps one by one and sync the db before each TestCase (and then run migration tests from that state).

Thanks in advance for looking into this, and thanks already for all the work put in Django so far!"	Bug	closed	Migrations	1.9	Release blocker	fixed	migrate, syncdb, migrations		Ready for checkin	1	0	0	0	0	0
