gpt4 book ai didi

php - 如何删除 Symfony2 项目中的实体类

转载 作者:可可西里 更新时间:2023-11-01 00:44:54 25 4
gpt4 key购买 nike

当我们最初设计我们的项目时,我们有几个迄今为止未使用的实体(我们不打算在不久的将来实现它们)。因此,我想将它们从我的项目中删除。我会这样进行(所有步骤手动执行):

  1. 从我当前使用的实体中删除所有关系。
  2. 删除doctrime ORM文件src/Resources/config/doctrine
  3. src/Entity 中删除类 PHP 文件>
  4. 从数据库中删除表

我想知道的是:是否有任何例程(例如控制台命令)可以支持此过程?例如,如果我运行

php app/console doctrine:schema:update --dump-sql

在删除所有关系并删除文件后,我得到了删除相应表的 SQL 语句?

最佳答案

从代码中删除实体后,您可以使用以下控制台命令删除表:

php bin/console doctrine:schema:update --complete --dump-sql

注意 --complete 选项的使用。


以下是 doctrine:schema:update 帮助文本中的相关部分:

Options:

--complete        If defined, all assets of the database which are not relevant to the current metadata will be dropped.
[...]

帮助:

[...]

Finally, be aware that if the --complete option is passed, this task will drop all database assets (e.g. tables, etc) that are not described by the current metadata. In other words, without this option, this task leaves untouched any "extra" tables that exist in the database, but which aren't described by any metadata.

Hint: If you have a database with tables that should not be managed by the ORM, you can use a DBAL functionality to filter the tables and sequences down on a global level:

$config->setFilterSchemaAssetsExpression($regexp);

关于php - 如何删除 Symfony2 项目中的实体类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21903264/

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