-
-
Notifications
You must be signed in to change notification settings - Fork 499
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
Unable to provide name for PK through naming strategy #2762
Comments
That link you mentioned is using The reason here is that we don't usually need to name a PK, and doing so would require additional query. PKs are not compared by name when diffing. So I would rather keep this as is, will check it later today to be sure, but I would rather not have this configurable and save one query for each table. The first branch could use the naming strategy, but as said, I am not sure if it's even valid, might be a dead code. edit: looking at the schema diffing snapshots, and we probably use separate query for anything that is not autoincrement, so it would be probably ok to use the PK name at least there. not sure how other drivers behave, I remember I was testing this and decided to keep default PK names |
Hmm okay, I can see it's more complex than what I thought. I might just rename the PKs in our existing data model then to reach some alignment. I'll give a moment, until your final call. |
Looks like the actual reason for this was mysql and sqlite, where the PK key name is forced to be |
Describe the bug
It is not actually possible to control the name of primary keys through a naming strategy, even in database drivers where it should be supported (postgres).
To Reproduce
Steps to reproduce the behavior:
"primary"
index type in the naming strategy.Expected behavior
Names of primary keys can be controlled when this should be supported by the database driver.
Additional context
The current naming behavior seems to be hardcoded at:
mikro-orm/packages/knex/src/schema/SchemaGenerator.ts
Line 484 in 0599032
I wasn't able to understand where the naming strategy would be referenced here.
Versions
The text was updated successfully, but these errors were encountered: