Yii2 - 迁移,外键约束失败

Yii2 - migration, a foreign key constraint fails

我使用迁移,创建 up() 是这样的:

$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 我收到错误

Cannot add or update a child row: a foreign key constraint fails ('crm'.'#sql-1524_46f', CONSTRAINT 'fk_presentation_place_user_id' FOREIGN KEY ('user_id') REFERENCES 'user' ('id') ON DELETE CASCADE ON UPDATE CASCADE)

我不知道哪里出了问题,我之前做过几次迁移,所以我真的很惊讶。

从错误信息来看我认为外键添加成功了,但是你在用户和 presentation_place 中有行。

尝试 运行 使用空 table 进行此迁移 设置存在于引用 table [=11= 中的默认值]

defaultValue(ALREADY_EXISTING_ID)