Php Yii2-迁移,外键约束失败

Php Yii2-迁移,外键约束失败,php,model-view-controller,yii2,database-migration,Php,Model View Controller,Yii2,Database Migration,我使用迁移,创建起来()如下: $this->addColumn('presentation_place', 'user_id', $this->integer()->notNull()->after('post_code')); $this->addForeignKey('fk_presentation_place_user_id', 'presentation_place', 'user_id', 'user', 'id', 'CASCADE', 'CASCAD

我使用迁移,创建起来()如下:

$this->addColumn('presentation_place', 'user_id', $this->integer()->notNull()->after('post_code'));
$this->addForeignKey('fk_presentation_place_user_id', 'presentation_place', 'user_id', 'user', 'id', 'CASCADE', 'CASCADE');
当yii/migrate时,我得到了一个错误

无法添加或更新子行:外键约束失败 ('crm'。#sql-1524_46f',约束'fk_演示文稿_地点_用户id' 外键('user_id')在上的删除级联上引用'user'('id') 更新(级联)


我不知道会出什么问题,我以前做过几次迁移,所以我真的很惊讶。

从错误消息中,我认为外键添加成功,但用户和演示文稿中都有行

尝试使用空表运行此迁移或设置引用表中存在的默认值

defaultValue(ALREADY_EXISTING_ID)

哇,我不相信它能起作用,但它真的解决了我的问题。我的意思是defaultValue()。谢谢佐尔坦!:)