#36565: Control column order in migrations
-----------------------------+--------------------------------------
     Reporter:  Rinshan      |                    Owner:  (none)
         Type:  New feature  |                   Status:  closed
    Component:  Migrations   |                  Version:  5.2
     Severity:  Normal       |               Resolution:  wontfix
     Keywords:               |             Triage Stage:  Unreviewed
    Has patch:  0            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  0
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+--------------------------------------
Comment (by Simon Charette):

 There exists another discussion about that (either on Trac or the django-
 dev mailing list) but I can't find it. IIRC the discussed points were

 1. Allowing re-ordering of fields would require the migration framework to
 ensure its `ModelState.fields` ordering is kept correctly. Today it's
 `dict[str, Field]` where order is not meaningful.
 2. It would require some shims on backends that don't support the
 [https://dev.mysql.com/doc/refman/8.0/en/alter-table.html#alter-table-add-
 drop-column MySQL specific] `ADD COLUMN AFTER` syntax such
 [https://wiki.postgresql.org/wiki/Alter_column_position as Postgres] which
 would likely involve re-creating the table anyway. Not sure about Oracle
 but we rebuild the table on SQLite on column addition in most cases so it
 should be an issue in this case.

 If your application has code that depends on column ordering it likely
 means that you have custom SQL anyway as the ORM abstracts that away
 entirely for you so using custom SQL through `RunSQL` or
 `SeparateDatabaseAndState` operation should not be a concern.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36565#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070198d746a16d-9ab2669b-a6e4-4195-bb7c-d75cd6421484-000000%40eu-central-1.amazonses.com.

Reply via email to