简体   繁体   English

从 symfony 4 中完全删除实体

[英]Completely delete Entity from symfony 4

this might be a noob question but here goes.这可能是一个菜鸟问题,但在这里。

I am learning symfony 4 and having just followed the guide about databases and doctrine i now have a new entity "Product.php" with an associated repository "ProductRepository.php" along with a new table in the db.我正在学习 symfony 4 并且刚刚遵循了关于数据库和学说的指南,我现在有一个新实体“Product.php”和一个关联的存储库“ProductRepository.php”以及数据库中的一个新表。 I want to now remove this entity/repository and update the database accordingly.我现在想删除这个实体/存储库并相应地更新数据库。

I thought I could simply remove Product.php and run php bin/console make:migration:diff我以为我可以简单地删除 Product.php 并运行 php bin/console make:migration:diff

However, nothing is getting changed.然而,一切都没有改变。 Is there some simple list of commands to remove all refs to the entity (I can't see any changes in config files - I am using annotations) or do I have to work out which files were created/modified and then go and manually drop the table.是否有一些简单的命令列表来删除对实体的所有引用(我看不到配置文件中的任何更改 - 我正在使用注释),或者我是否必须确定创建/修改了哪些文件,然后手动删除桌子。

Thank you,谢谢,

Martyn马丁

You can do it manually by deleting those files:您可以通过删除这些文件来手动执行此操作:

  1. src/Entity/Product.php源代码/实体/产品.php
  2. src/Repository/ProductRepository.php src/Repository/ProductRepository.php

If you have generated CRUD for your Product entity, you must delete:如果您为 Product 实体生成了 CRUD,则必须删除:

  1. src/Form/ProductType.php src/Form/ProductType.php
  2. src/Controller/ProductController.php src/Controller/ProductController.php
  3. templates/product (the product folder)模板/产品(产品文件夹)

If you are in production env, you must run php bin/console cache:clear to delete the cache before updating your database schema.如果您在生产环境中,则必须在更新数据库架构之前运行php bin/console cache:clear以删除缓存。 Then run php bin/console d:s:u --force然后运行php bin/console d:s:u --force

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM