-
Notifications
You must be signed in to change notification settings - Fork 150
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 naming convention #720
base: master
Are you sure you want to change the base?
Conversation
bdeafad
to
a8f618e
Compare
Thanks for the PR! I think I get your case and I'm with you on making this default, with only one concern: would it break existing applications? Say I remove a |
With the old version, actually you cannot downgrade constraints like removing unique, if you didn't set names in alembic migration files.
This pr doesn't actually break anything, it just makes the old pitfall obvious. |
Well, this is partially true - I got some time today and did some testing, looks like this PR will lead to an extra auto-generated Alembic revision to rename constraints for the new naming convention even the application code is unchanged at all, unless e.g. the existing unique constraint in the database (mapping to After thinking about alternative approaches (warn about new naming conventions in GINO 1.1 and actually add them in GINO 1.2), at the moment I'm leaning towards not adding default naming conventions in GINO, for the same reason why SQLAlchemy provides only default naming convention for indexes in the code, and other conventions in the documentation. Please see also sqlalchemy/sqlalchemy#4784. The naming may not be trivial and should be decided by the user. Though, I think we could definitely add |
Let the DB decide the constraint names is a bad idea in most cases - as far as I know. I'd rather see some consistent errors than not aware of hidden magic played by some database's some specific version. Say you didn't test downgrading and have brought it onto production, it'd be a total disaster if you'd like to downgrade the migration as long as The default naming convention is not a trivial API change. I agree to add it in the following version, but a warning for not defining naming convention should be released ASAP. By the way, alembic migration files should be reviewed and might be deleted, so it's not a big problem for me to generate index name changes - you can delete them anyway. |
Rationale:
This is basically a poka-yoke design, for
unique=True
FYI:
https://alembic.sqlalchemy.org/en/latest/naming.html