Repository: edgedb/edgedb

Issue:
Fail to create migration with interface pulled up
<!-- Please search existing issues to avoid creating duplicates. -->
- EdgeDB Version: EdgeDB CLI 2.0.5+da7c868
- OS Version:  win11

```
设备名称	IczpNet
处理器	Intel(R) Core(TM) i5-10500 CPU @ 3.10GHz   3.10 GHz
机带 RAM	32.0 GB (31.8 GB 可用)
设备 ID	23896D1D-266D-4756-BCC5-00AD4E2BB87F
产品 ID	00342-36059-40878-AAOEM
系统类型	64 位操作系统, 基于 x64 的处理器
笔和触控	没有可用于此显示器的笔或触控输入



版本	Windows 11 家庭中文版
版本	22H2
安装日期	‎2022/‎10/‎8
操作系统版本	22621.521
体验	Windows Feature Experience Pack 1000.22634.1000.0
```




Steps to Reproduce:

1. modify:

```diff
  # 媒体抽象（人、群、公众号、临时组） abstract
- abstract type IMediaEntity extending IFullAuditedObject{
+ abstract type IMediaEntity extending IFullAuditedObject, IIsActive{
      required property name ->str;
      property picture ->str;
   }

  # 用户
- type User extending IMediaEntity, IIsActive{
+ type User extending IMediaEntity{
      required property account ->str;    
  }
```

2. execute:

```
PS F:\Dev\edgedb\quickstart> edgedb migration create
Connecting to an EdgeDB instance at localhost:10701...
edgedb error: InternalServerError: 
  Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at https://github.com/edgedb/edgedb/issues/new?template=bug_report.md
  Server traceback:
      Traceback (most recent call last):
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler_pool/worker_proc.py", line 55, in worker
          res = meth(*args)
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler_pool/worker.py", line 185, in compile_in_tx
          units, cstate = COMPILER.compile_in_tx(cstate, *args, **kwargs)
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 2273, in compile_in_tx
          return self._compile(ctx=ctx, source=source), ctx.state
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1745, in _compile
          return self._try_compile(ctx=ctx, source=original)
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1812, in _try_compile
          comp, capabilities = self._compile_dispatch_ql(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1678, in _compile_dispatch_ql
          query = self._compile_ql_migration(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1165, in _compile_ql_migration
          guided_diff = s_ddl.delta_schemas(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/ddl.py", line 326, in delta_schemas
          sd.delta_objects(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/delta.py", line 221, in delta_objects
          alter = y.as_alter_delta(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/objects.py", line 3081, in as_alter_delta
          delta = super().as_alter_delta(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/objects.py", line 1775, in as_alter_delta
          sd.delta_objects(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/delta.py", line 221, in delta_objects
          alter = y.as_alter_delta(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/objects.py", line 3123, in as_alter_delta
          delta.discard(not_none(delta._get_attribute_set_cmd('ancestors')))
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/common/typeutils.py", line 36, in not_none
          assert x is not None
      AssertionError
PS F:\Dev\edgedb\quickstart> edgedb migration create
Connecting to an EdgeDB instance at localhost:10701...
edgedb error: InternalServerError: 
  Hint: This is most likely a bug in EdgeDB. Please consider opening an issue ticket at https://github.com/edgedb/edgedb/issues/new?template=bug_report.md
  Server traceback:
      Traceback (most recent call last):
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler_pool/worker_proc.py", line 55, in worker
          res = meth(*args)
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler_pool/worker.py", line 185, in compile_in_tx
          units, cstate = COMPILER.compile_in_tx(cstate, *args, **kwargs)
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 2273, in compile_in_tx
          return self._compile(ctx=ctx, source=source), ctx.state
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1745, in _compile
          return self._try_compile(ctx=ctx, source=original)
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1812, in _try_compile
          comp, capabilities = self._compile_dispatch_ql(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1678, in _compile_dispatch_ql
          query = self._compile_ql_migration(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/server/compiler/compiler.py", line 1165, in _compile_ql_migration
          guided_diff = s_ddl.delta_schemas(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/ddl.py", line 326, in delta_schemas
          sd.delta_objects(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/delta.py", line 221, in delta_objects
          alter = y.as_alter_delta(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/objects.py", line 3081, in as_alter_delta
          delta = super().as_alter_delta(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/objects.py", line 1775, in as_alter_delta
          sd.delta_objects(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/delta.py", linta.py", line 221, in delta_objects
          alter = y.as_alter_delta(
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/schema/objects.py", line 3123, in as_alter_delta
          delta.discard(not_none(delta._get_attribute_set_cmd('ancestors')))
        File "/home/edgedb/.local/share/edgedb/portable/2.3/lib/python3.10/site-packages/edb/common/typeutils.py", line 36, in not_none
          assert x is not None
      AssertionError
```

<!-- If the issue is about a query error, please also provide your schema -->
Schema:

```
module default {

# =============================================================================
  type Person {
    required property name -> str;
  }

  type Movie {
    # property title -> str;
    required property title -> str;
    multi link actors -> Person;
  }

# =============================================================================
# 公共实体

# 软删除
abstract type ISoftDelete{
    property is_deleted -> bool
}

# 是否活跃
abstract type IIsActive{
    property is_active -> bool
}

# -------------------------------------

# 创建人接口
abstract type IHasCreationTime{
    property creation_time -> datetime
}

# 创建人
abstract type IMayHaveCreator{
    link creator -> User
}

# 创建审计
abstract type ICreationAuditedObject extending IHasCreationTime, IMayHaveCreator{

}
# -------------------------------------

# 修改时间（最后修改时间）
abstract type IHasModificationTime{
    property last_modification_time -> datetime
}

# 修改人(最后修改人)
abstract type IMayHaveModifier{
    link last_modifier -> User
}

# 修改审计
abstract type IModificationAuditedObject extending IHasModificationTime, IMayHaveModifier{

}

# -------------------------------------

# 删除时间
abstract type IHasDeletionTime{
    property deletion_time -> datetime
}

# 删除人
abstract type IMayHaveDeleter{
    link deleter -> User
}

# 删除审计
abstract type IDeletionAuditedObject extending IHasDeletionTime, IMayHaveDeleter, ISoftDelete{

}

# 全审计
abstract type IFullAuditedObject extending ICreationAuditedObject, IModificationAuditedObject, IDeletionAuditedObject{

}


# =============================================================================
# 媒体类型
scalar type MediaTypeEnum extending enum<Person, Room, Ofifcal, OfficalGroup>;

# 群 Room
scalar type RoomTypeEnum extending enum<Free>;

# 官方 Offical
scalar type OfficalTypeEnum extending enum<Services, Subscribe>;

# 媒体抽象（人、群、公众号、临时组） abstract
  abstract type IMediaEntity extending IFullAuditedObject{
     required property name ->str;
     property picture ->str;
  }

# 用户
  type User extending IMediaEntity, IIsActive{
    required property account ->str;    
  }

# 群
  type Room extending IMediaEntity{
    property type -> RoomTypeEnum;
    multi link members -> RoomMember;
  }

# 群.成员
  type RoomMember extending IFullAuditedObject{
    link room -> Room;
    link member -> User;
  }

# 公众号
  type Offical extending IMediaEntity{
    property type -> OfficalTypeEnum;
    multi link members -> OfficalMember;
    multi link groups -> OfficalGroup;
  }

# 公众号.成员
  type OfficalMember extending IFullAuditedObject{
    link offical -> Offical;
    link member -> User;
  }

# 公众号.服务号临时组
  type OfficalGroup extending IMediaEntity{
    link offical -> Offical;
    multi link members -> OfficalGroupMember;
  }

# 公众号.服务号临时组.成员
  type OfficalGroupMember extending IFullAuditedObject{
    link offical_group -> OfficalGroup;
    link member -> User;
  }

# 消息
  type Message extending IFullAuditedObject{
    required property logId -> int16;
    required property sender -> str;
    required property sender_type -> MediaTypeEnum;
    required property receiver -> str;
    required property receiver_type -> MediaTypeEnum;

    # required property senderMedia -> IMediaEntity;

    required property content -> str;

    # links
  }

# 消息内容
abstract type IContent extending IFullAuditedObject{
    # abstract messageType;
    multi link messages -> Message
}


# 文本内容
type TextContent extending IContent{
 required property text -> str;

}

# cmd内容
type CmdContent extending IContent{
 required property text -> str;
required property cmd -> str;

}

# 图片内容
type ImageContent extending IContent{
    # image url
 required property url -> str;
 required property thumb -> str;
 property width -> int16;
 property height -> int16;
}

# 视频内容
type VideoContent extending IContent{
    # video url
 required property url -> str;
 
  property width -> int16;
  property height -> int16;
  property size -> int16;

  property image -> str;
  property image_width -> int16;
  property image_height -> int16;
  property image_size -> int16;
}

# 语音内容
type SoundContent extending IContent{
    # video url
  required property url -> str;
  property time -> int16;
}

# 文件内容
type FileContent extending IContent{
    # video url
  required property url -> str;
  property time -> int16;
  required property file_name -> str;
  property content_length -> str;
  property content_type -> str;
  property suffix -> str;
}
};
```



Discussion:

Resolving patch:
diff --git a/edb/schema/objects.py b/edb/schema/objects.py
--- a/edb/schema/objects.py
+++ b/edb/schema/objects.py
@@ -3120,7 +3120,9 @@ def as_alter_delta(
             # Trim these from the base alter since they are redundant
             # and clog up debug output.
             delta.discard(not_none(delta._get_attribute_set_cmd('bases')))
-            delta.discard(not_none(delta._get_attribute_set_cmd('ancestors')))
+            # ancestors might not be in the delta, if it didn't change
+            if anc := delta._get_attribute_set_cmd('ancestors'):
+                delta.discard(anc)
 
             delta.add(rebase_cmd)
 


Test patch:
diff --git a/tests/test_edgeql_data_migration.py b/tests/test_edgeql_data_migration.py
--- a/tests/test_edgeql_data_migration.py
+++ b/tests/test_edgeql_data_migration.py
@@ -11153,6 +11153,23 @@ async def test_edgeql_migration_alias_linkprop_01(self):
             type Target;
         """)
 
+    async def test_edgeql_migration_lift_01(self):
+        await self.migrate(r"""
+            abstract type A;
+            abstract type B;
+
+            abstract type Foo extending A;
+            type Bar extending Foo, B;
+        """)
+
+        await self.migrate(r"""
+            abstract type A;
+            abstract type B;
+
+            abstract type Foo extending A, B;
+            type Bar extending Foo;
+        """)
+
 
 class TestEdgeQLDataMigrationNonisolated(EdgeQLDataMigrationTestCase):
     TRANSACTION_ISOLATION = False