这是一个奇怪的一个无法删除的对象,由于外键约束
采用此架构:
Contact:
actAs: [Timestampable,SoftDelete]
columns:
first_name: { type: string(255), notnull: true }
second_name: { type: string(255), notnull: true }
relations:
Forums:
class: Forum
refClass: ContactForum
local: forum_id
foreign: contact_id
foreignAlias: Contacts
ContactForums:
local: id
foreign: contact_id
class: ContactForum
type: many
foreignType: one
cascade: [delete]
Forum:
actAs: [Timestampable,SoftDelete]
columns:
name: { type: string(255), notnull: true }
relations:
ContactForums:
class: ContactForum
local: id
foreign: forum_id
type: many
cascade: [delete]
ContactForum:
actAs: [Timestampable]
columns:
contact_id: { type: integer, primary: true }
forum_id: { type: integer, primary: true }
然后,如果我们到Contact
对象几个Forum
对象的关联,然后试着删除此Contact
对象,我们收到此错误信息:
完整性约束违规:19 contact_forum.created_at可能无法 NULL
如果您将SoftDelete添加到链接表中,则删除工作正常,SoftDelete也会正常工作。但是,我们不希望链接表上的SoftDelete,因为它意味着我们的主键无法正常工作。这是一个错误?
由于doctrine 1.2 trac已经关闭,解决这个问题的最好方法是为关系定义onDelete:CASCADE(并且可能会将softDelete行为添加到其他实体) – glerendegui 2016-02-19 19:55:41