php - 使用 ORM 但没有 Symfony 的 Doctrine 2 迁移
问题描述
我构建了使用 Symfony 组件的应用程序,但只是少数。这意味着我不使用集成包。
我想使用教义。目前,我在将 Doctrine ORM 与 Doctrine 迁移集成时遇到问题。
我已经安装
"doctrine/migrations": "^1.8",
"doctrine/dbal": "^2.8",
"doctrine/orm": "^2.6",
"symfony/console": "^4.1"
和其他几个 Symfony 模块。但我不使用标准的 Symfony 配置目录。我已经配置好migrations.xml
了migrations-db.php
我在App\Infractructure\Entities
.
示例实体
命名空间 Iaso\Entities;
/** @Entity */
class User
{
/** @Id
* @Column(type="integer")
* @GeneratedValue
*/
private $id;
/** @Column(length=150) */
private $email;
/** @Column(length=255) */
private $password;
/** @Column(length=150, name="first_name") */
private $firstName;
/** @Column(length=150, name="last_name") */
private $lastName;
/** @Column(type="datetime", name="posted_at") */
private $postedAt;
/** @Column(type="datetime", name="updated_by") */
private $updatedAt;
/** @OneToOne(targetEntity="User")
* @JoinColumn(name="updated_by", referencedColumnName="id")
*/
private $updatedBy;
}
我可以创建一个空的迁移文件,我可以运行我手动创建的迁移。我想使用 ORM 和基于与当前数据库的实体差异的自动迁移。
我看到一些问题。
- 我在控制台命令 migrations:diff 中看不到,我不知道为什么
- 我确定我需要告诉迁移知道我的实体在哪里,但我不知道如何。我阅读了文档并尝试直接在命令中在 Doctrine GitHub 上找到一些东西。我找不到任何有趣的东西。
感谢您的任何提示。
解决方案
推荐阅读
- asp.net-mvc - 带有天蓝色前门的错误请求 uri
- vba - VBA 循环未从 Excel 正确粘贴
- python - 从上一帧返回相同函数的函数已创建
- c3.js - 在 C3.js 中更改网格颜色
- javascript - CleaveJS phoneRegionCode 在 React 中不起作用
- javascript - 这是从数组创建列表的正确方法吗?
- html - 在子组件中向上滚动时会触发离子刷新器
- android - 使用 PowerMockito 测试 Android 原生代码
- c# - .net 核心应用程序在 docker 容器中的内存快照
- knex.js - 如何从 objection.js 中获取所有行