我与像这样构造的typeor有很多关系:
在 PostEntity 类中
@PrimaryGeneratedColumn('uuid')
id: string;
@ManyToOne(type => UserEntity, user => user.posts)
userPosted: UserEntity;
在 UserEntity 类
中@PrimaryGeneratedColumn('uuid')
id: string;
@OneToMany(type => PostEntity, c => c.userPosted)
posts: PostEntity[];
我可以成功创建迁移,但是当我尝试运行迁移时会引发错误:
查询失败:ALTER TABLE“ post”添加约束 “ FK_f36f38b0231a9075541aae12b73”外键(“ user_posted_id”) 参考“ user”(“ id”)ON删除无操作更新无操作错误: {错误:没有唯一的约束匹配给定的键 引用表“用户”
我只是关注文档。不知道为什么迁移不会在数据库中更新。 迁移文件:https://gist.github.com/DooMachine/fe6a34817ed763941d74097acd4a4efd