# Buggy code
def _create_innards(self, schema, context):
    schema = super()._create_innards(schema, context)

    referrer_ctx = self.get_referrer_context(context)
    if referrer_ctx is None:
        return schema

    referrer = referrer_ctx.scls
    referrer_cls = type(referrer)
    mcls = type(self.scls)
    refdict = referrer_cls.get_refdict_for_class(mcls)

    if refdict.backref_attr:
        # Set the back-reference on referenced object
        # to the referrer.
        schema = self.scls.set_field_value(schema, refdict.backref_attr, referrer)

    schema = referrer.add_classref(schema, refdict.attr, self.scls)

    if isinstance(referrer, inheriting.InheritingObject):
        if not context.canonical:
            # Propagate the creation of a new ref to descendants.
            alter_cmd = sd.ObjectCommandMeta.get_command_class_or_die(
                sd.AlterObject, referrer_cls
            )

            ref_field_type = referrer_cls.get_field(refdict.attr).type
            refname = ref_field_type.get_key_for(schema, self.scls)

            if context.enable_recursion:
                for child in referrer.children(schema):
                    alter = alter_cmd(classname=child.get_name(schema))
                    with alter.new_context(schema, context, child):
                        schema, cmd = self._propagate_ref_creation(
                            schema, context, refdict, refname, child
                        )
                        alter.add(cmd)
                    self.add(alter)
        else:
            for op in self.get_subcommands(metaclass=referrer_cls):
                schema, _ = op.apply(schema, context=context)

    return schema


# Traceback (edb.schema.objects.FieldValueNotFoundError)
Traceback (most recent call last):
File "/home/victor/dev/magicstack/edgedb/tests/test_schema.py", line 2084, in test_migrations_equivalence_annotation_01
"""])
File "/home/victor/dev/magicstack/edgedb/tests/test_schema.py", line 603, in _assert_migration_equivalence
self._assert_migration_consistency(migrations[-1])
File "/home/victor/dev/magicstack/edgedb/tests/test_schema.py", line 588, in _assert_migration_consistency
diff = s_ddl.delta_schemas(baseline_schema, test_schema)
File "/home/victor/dev/magicstack/edgedb/edb/schema/ddl.py", line 87, in delta_schemas
old, new, old_schema=schema2, new_schema=schema1))
File "/home/victor/dev/magicstack/edgedb/edb/schema/objects.py", line 1143, in delta_sets
their_schema=old_schema)
File "/home/victor/dev/magicstack/edgedb/edb/schema/objects.py", line 778, in compare
context=context)
File "/home/victor/dev/magicstack/edgedb/edb/schema/objects.py", line 796, in compare_field_value
compcoef=field.compcoef or 0.5)
File "/home/victor/dev/magicstack/edgedb/edb/schema/objects.py", line 1466, in compare_values
their_schema=their_schema, context=context))
File "/home/victor/dev/magicstack/edgedb/edb/schema/objects.py", line 770, in compare
their_value = other.get_field_value(their_schema, field_name)
File "/home/victor/dev/magicstack/edgedb/edb/schema/objects.py", line 642, in get_field_value
schema, field_name, allow_default=allow_default)
File "/home/victor/dev/magicstack/edgedb/edb/schema/objects.py", line 635, in _get_schema_field_value
f'{self!r} object has no value for field {field_name!r}')
edb.schema.objects.FieldValueNotFoundError: <AnnotationValue: at 0x7f27da85bf60> object has no value for field 'annotation'

# Fixed code
def _create_innards(self, schema, context):
    schema = super()._create_innards(schema, context)

    referrer_ctx = self.get_referrer_context(context)
    if referrer_ctx is None:
        return schema

    referrer = referrer_ctx.scls
    referrer_cls = type(referrer)
    mcls = type(self.scls)
    refdict = referrer_cls.get_refdict_for_class(mcls)

    if refdict.backref_attr:
        # Set the back-reference on referenced object
        # to the referrer.
        schema = self.scls.set_field_value(schema, refdict.backref_attr, referrer)

    schema = referrer.add_classref(schema, refdict.attr, self.scls)

    if not self.scls.get_is_final(schema) and isinstance(
        referrer, inheriting.InheritingObject
    ):
        if not context.canonical:
            # Propagate the creation of a new ref to descendants.
            alter_cmd = sd.ObjectCommandMeta.get_command_class_or_die(
                sd.AlterObject, referrer_cls
            )

            ref_field_type = referrer_cls.get_field(refdict.attr).type
            refname = ref_field_type.get_key_for(schema, self.scls)

            if context.enable_recursion:
                for child in referrer.children(schema):
                    alter = alter_cmd(classname=child.get_name(schema))
                    with alter.new_context(schema, context, child):
                        schema, cmd = self._propagate_ref_creation(
                            schema, context, refdict, refname, child
                        )
                        alter.add(cmd)
                    self.add(alter)
        else:
            for op in self.get_subcommands(metaclass=referrer_cls):
                schema, _ = op.apply(schema, context=context)

    return schema