gpt4 book ai didi

symfony - Doctrine 2 如何防止丢失外键

转载 作者:行者123 更新时间:2023-12-02 02:11:09 26 4
gpt4 key购买 nike

我目前正在使用 Symfony2 和 Doctrine。我直接在我的数据库中添加了一些外键,而没有使用 Doctrine 中的关系。似乎每次我执行 doctrine:schema:update --force 时,我所有的外键都会被删除。这可以通过运行 doctrine:schema:update --dump-sql 来验证。

有什么方法可以防止 doctrine 删除手动创建的外键?或者有没有一种方法可以使用没有关系的注释创建外键?

最佳答案

sgoettschkes ,我认为不可能完全按照您的要求进行操作(但是您可以为将来的版本写一张关于它的票!我什至没有找到它,这似乎是个好主意..!):

I don't think so. You should decide between either using doctrine and having your database schema 100% defined by it or not using the update at all (changing the database manually).

但是,在那之前,我建议您使用 native SQL 编写一个脚本并在您的学说模式中(之后)运行它:更新内容。

关于symfony - Doctrine 2 如何防止丢失外键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12776025/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com