﻿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
7556	inspectdb fails in MySql if a table references a table outside the current schema	brockweaver		"If a table contains a foreign key that refers to another table that sits outside the schema, that index includes a '.' in the table name.  Suppose our current schema is `schema1`:
{{{
CREATE TABLE `T1` (
  `ACID` int(8) unsigned NOT NULL,
  `SITE` varchar(8) character set latin1 default NULL,
  CONSTRAINT `FK_T1_SITE` FOREIGN KEY (`SITE`) REFERENCES `schema2`.`site` (`SITE`)
)
}}}

For this situation, inspectdb will return something similar to this:
{{{
_mysql_exceptions.ProgrammingError: (1146, ""Table 'schema1.site' doesn't exist"")
}}}
So it tries to use `schema1.site` as the table to introspect instead of the appropriate `schema2`.`site`  Notice it not only needs to use the schema as part of the table name, but also not quote the '.'.  Also, introspection.py was not pulling the schema name and just assuming the current schema, which for most cases is right, but in this case causes issues for legacy databases.

"	Bug	new	Core (Management commands)	dev	Normal		mysql foreign key schema inspectdb		Accepted	1	0	1	0	0	0
