- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我对 Doctrine Migrations 还很陌生,如果这真的很明显,我深表歉意。
已更新以提供更多信息
我有一个 Symfony2 实体映射如下:
/**
* @ORM\Column(type="string")
*/
private $name;
这已添加到迁移并部署,一切正常。然后需要更新该列以接受空值,因此将其更改为:
/**
* @ORM\Column(type="string", nullable=true)
*/
private $name;
问题是这对生成的迁移文件没有影响:
$ php app/console cache:clear
$ php app/console doctrine:migrations:diff
$ tail -50 app/DoctrineMigrations/Version20131028205742.php
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20131028205742 extends AbstractMigration
{
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
}
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql", "Migration can only be executed safely on 'mysql'.");
}
}
没有添加任何 ALTER 语句来处理空值。我可以删除并重建数据库,但是由于已经部署了这个特定的迁移,这将导致生产数据库出现问题。我可以看到这种情况在未来再次发生,所以想多了解一点。
这是 Doctrine 和/或 Symfony2 Doctrine 迁移包的限制吗?有没有办法在不编写自定义迁移的情况下解决这个问题?
请注意,我的所有其他迁移工作正常,唯一的问题是向现有字段添加可为空的选项。
最佳答案
Doctrine 的 diff 以这种方式工作,它将您的实体元数据与现有数据库模式进行比较。因此,如果您运行 doctrine:schema:update
after 您已经运行了迁移 - doctrine 不会注意到任何变化,因为数据库架构已经更改(因此适合实体元数据)。基本上在您运行迁移之后,您不再需要运行 update
。
关于php - 学说迁移 : altering a column to be nullable in production,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19631664/
我几乎尝试了所有方法来尝试创建代表我的数据库架构的实体,但仍然存在整页错误。如果有人能给我一些启发,我将不胜感激。 基本上我们有两份注册表,一份用于品牌,一份用于影响者。在每个表单中,我们都会要求您提
我有关于双向 OneToMany ManyToOne 的问题我的实体之间的关系 Device和 Event .这是映射的样子: // Device entity /** * @OR
我有一些具有一对多/多对一关系的实体 - 生产类- /** * @OneToMany(targetEntity="ProductionsKeywords", mappedBy="production
我正在使用 symfony 2.3 和 doctrine 2.2。我创建了一个控制台命令,以便在数据库中插入一些数据。当我尝试用当前日期更新时间列时,我收到此错误 Catchable fata
我想用 limit 做一个 fetchAll() 吗?您知道 symfony2 的实体管理器是否可行吗? 我当前的代码(获取所有,无限制): $repository = $this->getDoctr
客户需要根据需要更改项目的顺序,这意味着我需要一些“顺序”或“顺序”列来保存每个项目的实际位置。 如何使用 Doctrine 2 来实现这一点? 最佳答案 我会使用 Doctrine 的 event
在 Symfony2/Doctrine 中插入记录后触发事件的最佳方法是什么? 最佳答案 首先,将服务注册为 Doctrine 事件监听器: app/config.yml: services:
我很难让这个doctrine2扩展发挥作用。是https://github.com/djlambert/doctrine2-spatial关于如何创建多边形的文档并不多。我已经让配置文件正常工作了,但
我正在尝试对我的 FacebookEventResult 实体执行 native 查询,并创建与我的 FacebookEvent 实体的连接。 FacebookEventResult中的相关映射: /
我使用 SyliusSandbox 包开发商店。Sylius 使用 xml 文件来存储实体的 ORM 模式。 我已经将它的 xml 定义复制到我的 Bundle 中并在那里使用它。 但对于我自己的
客户需要根据需要更改项目的顺序,这意味着我需要一些“顺序”或“顺序”列来保存每个项目的实际位置。 如何使用 Doctrine 2 来实现这一点? 最佳答案 我会使用 Doctrine 的 event
我有以下查询: $em = $this->getEntityManager(); $query = $em->createQueryBuilder()->select('shopp
我定义了两个数据库实体 项目: use Doctrine\ORM\Mapping as ORM; use \Kdyby\Doctrine\Entities\MagicAccessors; /** *
我想要的是得到产品,产品应该是这样的: { idProduct: 1, mainCategory: 1, // One of the categories is the main one.
我使用以下查询: SELECT u.username, u.password, s.name, s.price FROM AcmeBundle:User u LEFT JOIN AcmeBundle:
我做了一些研究来回答它,但我没有找到。 我想知道在以下之间进行选择(加入)的最佳做法是什么: 使用查询生成器? $this->getEntityManager()->createQueryBuilde
我对原则 2 有疑问。我有以下数据库表:因此,Doctrine 生成从站点的桌面设置中检索数据的实体,但我需要从 desk_settings 表中检索所有设置并使用 desk_id 从 desk_se
我有两个实体,用户和客户端,一个客户端可以有很多用户。 通常我想要一个用户实体并延迟加载客户端,但由于某些原因,当我尝试访问其属性时,客户端代理不会自行加载。 如果我像这样转储数据 \Doctrine
我在验证方面遇到问题。在 Doctrine 1 中,我使用了这个: if ($model->isValid()) { $model->save(); } else { $errorSt
我将以下实体映射到 Doctrine 2 : class Zone { /** * @ManyToOne(targetEntity="Zone", inversedBy="child
我是一名优秀的程序员,十分优秀!