                          name=index.name,
                      ),
                  )
  
      def create_altered_constraints(self):
          option_name = operations.AddConstraint.option_name
          for app_label, model_name in sorted(self.kept_model_keys):
              old_model_name = self.renamed_models.get(
                  (app_label, model_name), model_name
              )
 
</s> remove             add_idx = [idx for idx in new_indexes if idx not in old_indexes]
            rem_idx = [idx for idx in old_indexes if idx not in new_indexes]
 </s> add             added_indexes = [idx for idx in new_indexes if idx not in old_indexes]
            removed_indexes = [idx for idx in old_indexes if idx not in new_indexes]
            renamed_indexes = []
            # Find renamed indexes.
            remove_from_added = []
            remove_from_removed = []
            for new_index in added_indexes:
                new_index_dec = new_index.deconstruct()
                new_index_name = new_index_dec[2].pop("name")
                for old_index in removed_indexes:
                    old_index_dec = old_index.deconstruct()
                    old_index_name = old_index_dec[2].pop("name")
                    # Indexes are the same except for the names.
                    if (
                        new_index_dec == old_index_dec
                        and new_index_name != old_index_name
                    ):
                        renamed_indexes.append((old_index_name, new_index_name, None))
                        remove_from_added.append(new_index)
                        remove_from_removed.append(old_index)
            # Remove renamed indexes from the lists of added and removed
            # indexes.
            added_indexes = [
                idx for idx in added_indexes if idx not in remove_from_added
            ]
            removed_indexes = [
                idx for idx in removed_indexes if idx not in remove_from_removed
            ] </s> remove                         "added_indexes": add_idx,
                        "removed_indexes": rem_idx,
 </s> add                         "added_indexes": added_indexes,
                        "removed_indexes": removed_indexes,
                        "renamed_indexes": renamed_indexes,
    def generate_renamed_indexes(self):
        for (app_label, model_name), alt_indexes in self.altered_indexes.items():
            for old_index_name, new_index_name, old_fields in alt_indexes[
                "renamed_indexes"
            ]:
                self.add_operation(
                    app_label,
                    operations.RenameIndex(
                        model_name=model_name,
                        new_name=new_index_name,
                        old_name=old_index_name,
                        old_fields=old_fields,
                    ),
                )

                          name=index.name,
                      ),
                  )
  
    def generate_renamed_indexes(self):
        for (app_label, model_name), alt_indexes in self.altered_indexes.items():
            for old_index_name, new_index_name, old_fields in alt_indexes[
                "renamed_indexes"
            ]:
                self.add_operation(
                    app_label,
                    operations.RenameIndex(
                        model_name=model_name,
                        new_name=new_index_name,
                        old_name=old_index_name,
                        old_fields=old_fields,
                    ),
                )

      def create_altered_constraints(self):
          option_name = operations.AddConstraint.option_name
          for app_label, model_name in sorted(self.kept_model_keys):
              old_model_name = self.renamed_models.get(
                  (app_label, model_name), model_name
              )
keep keep keep add keep keep keep keep keep keep
 Refs #27064 -- Made migrations generate RenameIndex operations when renaming Meta.indexes. 
django/db/migrations/autodetector.py