加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 在Symfony 2 / Doctrine 2中是否有“generate-migrations

发布时间:2020-12-13 21:48:55 所属栏目:PHP教程 来源:网络整理
导读:以下是解释“generate-migrations-db”的内容的遗留文档: http://symfony.com/legacy/doc/doctrine/1_2/en/07-Migrations 它说 Generate migration classes from existing database connections (doctrine-generate-migrations-db,doctrine-gen-migrations-
以下是解释“generate-migrations-db”的内容的遗留文档:

http://symfony.com/legacy/doc/doctrine/1_2/en/07-Migrations

它说

Generate migration classes from existing database connections
(doctrine-generate-migrations-db,doctrine-gen-migrations-from-db)

也:

Generating Migrations

Doctrine offers the ability to generate sets of
migration classes for existing databases or existing models as well as
generating blank migration classes for you to fill in with the code to
make your schema changes.

From Database

If you have an existing database you can build a set of migration
classes that will re-create
your database by running the following
command.

$./symfony doctrine:generate-migrations-db

换句话说:它从数据库中获取模式并生成执行模式创建的迁移.在此过程中不使用任何实体,没有类,也不使用映射.它只需要一个DB并构建一个迁移类.

我们不再有generate-migrations-db了.我们有什么能完成这项任务吗?我找不到.如果被其他命令取代,请告诉我.如果刚删除,请告知.

解决方法

我不知道Doctrine或Migrations Bundle中为现有数据库创建迁移文件的命令.

所以这就是我如何做到的:

>安装DoctrineMigrationsBundle
>创建一个新的空白数据库
>更新您的配置或参数以指向此空白数据库而不是您的“真实”数据库
>运行php app / console doctrine:migrations:diff.这将创建一个从头开始创建数据库表等的迁移文件
>更改您的配置/参数

希望这是有帮助的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读