diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py index b429e6a3cf8b..21d1e4f4b610 100644 --- a/django/db/backends/mysql/introspection.py +++ b/django/db/backends/mysql/introspection.py @@ -178,6 +178,8 @@ def get_constraints(self, cursor, table_name): 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():