Symfony / Doctrine重新排列数据库列 [英] Symfony/Doctrine Rearranging Database Columns

查看:82
本文介绍了Symfony / Doctrine重新排列数据库列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我去使用doctrine:schema:update命令行来生成表时,看起来Doctrine(或Symfony?)想要抛出一个重新排列列的命令,把键放在前面会出现。我想知道,如果更有希望在哪里,我可以禁用环境的这个功能,所以当我去生成我的表格时,它们按照我输入到orm的顺序。



我已经看了这个问题,但似乎没有人能从我能够想出来的,而我不知道什么捆绑/部分的教义或Symfony需要改变,不希望重新排列我的桌子。任何信息,只是什么部分的捆绑包将包含这个逻辑,或者我可以添加什么选项来改变它将不胜感激,因为我无法真正找到任何文件到目前为止。



更新:
我做了一些调查,我发现一个类似于我的溢出问题,但不完全相同。在我的情况下,我没有使用新的数据类型,唯一向前移动的列是我指定为键(主键或外键)的键。它抛出的命令看起来非常类似于这一点,除了它是对每一个我的钥匙。

  ALTER TABLE product_price CHANGE价格价格DECIMAL(10,2)DEFAULT NULL 

教义自定义类型总是更改表



更新2:请求的其他信息:
以.orm.yml格式运行MySQL。



要设置的字段始终是关键字段,并且在将其更改为我想要/需要它们的顺序之后,则感觉需要重新排列每一列再次出现。



我不改变任何关于字段的内容;它在初始创建时,以及每当我需要运行模式更新,而不对这些特定字段进行任何更改。

解决方案

我做了一些挖掘,我不认为你可以控制这个:



https://github.com/doctrine/dbal/blob/master/lib/Doctrine/ DBAL / Schema / Table.php#L555



按此顺序,顺序是PK,FK和其他列。
通过原始逻辑的页面扫描是很困难的,所以我可能错过了一些东西,但是从我可以看出,它不是在任何配置上作出决定的顺序。


When I go to generate a table using the doctrine:schema:update command line, it appears that Doctrine(or Symfony?) wants to throw in a command that rearranges my columns, putting the keys towards the front it would appear. I was wondering if, and more hopefully, where, I can disable this "feature" of the Environment, so when I go to generate my tables, they are kept in the order which I entered them into the orm.

I've looked around for this problem, but it would seem that no one else has it from what I've been able to come up with, and I'm not certain what bundle/part of Doctrine or Symfony I need to alter to have it not desire to rearrange my tables. Any information as to just what part of the bundle would contain this logic, or what option I can add to alter it would be greatly appreciated, as I'm unable to really find anything in the documentation so far.

Update: I did some investigating, and I found an overflow question similar to mine, but not quite. In my case, I'm NOT using new datatypes, and the only columns moved forward are the ones that I've designated as being keys (Primary, or Foreign). The commands that it throws me looks VERY similar to this, except it's doing it to each and every one of my keys.

ALTER TABLE product_price CHANGE price price DECIMAL(10,2) DEFAULT NULL

Doctrine custom type always altering table

Update 2: Additional information as requested: Running MySQL under a .orm.yml format.

The fields it wants to set are always the key fields, and after I change them back to the order I want/need them in, it then feels the need to rearrange the columns again every time.

I don't change anything about the fields; it does this both on initial creations, as well as whenever I need to run the schema update, without any changes to those specific fields.

解决方案

I did a bit of digging, and I don't think you can have any control over this:

https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Schema/Table.php#L555

Judging by this, the order is PK, FK, and other columns, in that order. It is difficult scanning through pages of raw logic so I may have missed something, but from what I can tell it is not acting on any configuration to decide the order.

这篇关于Symfony / Doctrine重新排列数据库列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆