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.
Advertisement
Answer
I did a bit of digging, and I don’t think you can have any control over this. See getColumns() [1] [2]
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.
[1] (at the time of the answer; Nov 2013) https://github.com/doctrine/dbal/blob/5ffb052a2e622908c988f79e9a099f5d64f40b34/lib/Doctrine/DBAL/Schema/Table.php#L555
[2] (updated line number; June 2020) https://github.com/doctrine/dbal/blob/2.10.x/lib/Doctrine/DBAL/Schema/Table.php#L595