diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index 9520e890eaf..56280b6fe5e 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -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():