﻿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
22183	Migrations don't work with custom through table on M2M fields	Florian Apolloner	Andrew Godwin	"Given those models:
{{{
from django.db import models
#from taggit.managers import *


class M2M(models.Model):
    test1 = models.ForeignKey('Test1', related_name='+')
    test2 = models.ForeignKey('Test2', related_name='+')

class Test1(models.Model):
    pass

class Test2(models.Model):
    m2m = models.ManyToManyField(Test1, through=M2M)

#class Test3(models.Model):
#    tags = TaggableManager()
}}}

The created schema will look like:
{{{
CREATE TABLE ""testing_test1"" (""id"" integer NOT NULL PRIMARY KEY AUTOINCREMENT);
CREATE TABLE ""testing_test2"" (""id"" integer NOT NULL PRIMARY KEY AUTOINCREMENT);
CREATE TABLE ""testing_test2_m2m"" (""id"" integer NOT NULL PRIMARY KEY AUTOINCREMENT, ""test2_id"" integer NOT NULL REFERENCES ""testing_test2"" (""id""), ""test1_id"" integer NOT NULL REFERENCES ""testing_test1"" (""id""), UNIQUE (""test2_id"", ""test1_id""));
CREATE TABLE ""testing_m2m"" (""id"" integer NOT NULL PRIMARY KEY AUTOINCREMENT, ""test1_id"" integer NOT NULL REFERENCES ""testing_test1"" (""id""), ""test2_id"" integer NOT NULL REFERENCES ""testing_test2"" (""id""));
}}}
The issue here is that there is a table named ""testing_test2_m2m"" which shouldn't be there!

Attached you will find a full project demonstrating this issue."	Bug	closed	Migrations	dev	Release blocker	fixed	sql, migrations, m2m	Florian Apolloner info@…	Accepted	0	0	0	0	0	0
