diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index f28c89c..a939d42 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -577,6 +577,18 @@ class MigrationAutodetector(object):
                 for name, field in sorted(related_fields.items())
             ]
             related_dependencies.append((app_label, model_name, None, True))
+            if order_with_respect_to:
+                self.add_operation(
+                    app_label,
+                    operations.AlterOrderWithRespectTo(
+                        name=model_name,
+                        order_with_respect_to=order_with_respect_to,
+                    ),
+                    dependencies=[
+                        (app_label, model_name, order_with_respect_to, True),
+                        (app_label, model_name, None, True),
+                    ]
+                )
             if unique_together:
                 self.add_operation(
                     app_label,
@@ -595,18 +607,6 @@ class MigrationAutodetector(object):
                     ),
                     dependencies=related_dependencies
                 )
-            if order_with_respect_to:
-                self.add_operation(
-                    app_label,
-                    operations.AlterOrderWithRespectTo(
-                        name=model_name,
-                        order_with_respect_to=order_with_respect_to,
-                    ),
-                    dependencies=[
-                        (app_label, model_name, order_with_respect_to, True),
-                        (app_label, model_name, None, True),
-                    ]
-                )
 
     def generate_created_proxies(self):
         """
