-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for preserving field order? #1539
Comments
Hi, I'm not sure how portable would be such a solution. Looking fairly quickly at some db, mysql seems the only one that supports it, postgresql, oracle and sql server do not support it. I guess we could add |
Thanks, I did think it was probably going to have to be manual unless there was something that could be done with |
it may be automated I guess, but first we would need to support it. Since db support seems only mysql, if we were to support some sort automation that would be behind a config parameter, since it would be a bit annoying having that rendered by default for people who never plan on using mysql. @zzzeek do you have any consideration about this? @msaysell a PR to add manual support for it would be accepted, let's wait for mike regarding whatever we should also thing about automating something. |
there's a bunch going on if we are taking this to be automated all the way from the ORM model with mixins as in the top example, there are strict rules about how the ORM orders columns in these cases, which can be affected manually using mapped_column.sort_order. once we get a so yes in this case we would add |
yes, the automation here would just be looking at the position in the sqlalchemy table. A recipe is likely a better first automation step |
Describe the use case
As far as I can tell, there doesn't seem to be a way to specify field order when adding a new column? Ive got an inherited model where it would be nice if any new fields that I create via an autogenerated revision would be entered into the database before the base classes fields.
I know I could manually add an
execute
after adding it to alter the table to insert it after another field but that sounds tedious to enforce and a way to preserve field order would be useful.Databases / Backends / Drivers targeted
mysql in this example
Example Use
The
new_field
will be created at the end of the tablewhere I'd like to have a way to insert it before a field
Have a nice day!
The text was updated successfully, but these errors were encountered: