Fixed -- Made MySQL backend retrieve constraint columns in their defined order.
@@ -160,6 +160,7 @@ class DatabaseIntrospection(BaseDatabaseIntrospection):
WHERE
kc.table_schema = DATABASE() AND
kc.table_name = %s
+ ORDER BY kc.`ordinal_position`
"""
cursor.execute(name_query, [table_name])
for constraint, column, ref_table, ref_column in cursor.fetchall():
