Open matthewjumpsoffbuildings opened 11 months ago
Is there already a proper way to do this using this driver?
No, you will have to add the constraints manually.
I see there is an existing library for composite keys in Eloquent in general, https://github.com/thiagoprz/eloquent-composite-key - is that compatible with this driver perhaps?
You can try, but I don't think that trait covers complex cases like relations.
We use this library too. Laravel does not seem to support composite keys in certain circumstances. Laravel only identifies data with the primaryKey type "string". But when using the library https://github.com/thiagoprz/eloquent-composite-key, it identifies string or array as primary key
For complex relationships we use https://github.com/tylernathanreed/laravel-composite-relations
But when using the library https://github.com/thiagoprz/eloquent-composite-key, it identifies string or array as primary key
That is not aligned with how laravel does things and may result in errors where string is expected to return from$model->getKey()
so it may make upgrading to newer versions hard and painful.
For complex relationships we use https://github.com/tylernathanreed/laravel-composite-relations.
This overrides a lot of the logic from the base framework and that's quite risky when upgrading the underlying framework.
When at scale, Spanner docs often suggest using composite keys for the primary key, for example using a
ShardId
combined with the other columns, something likePRIMARY KEY (ShardId, Id)
Is there already a proper way to do this using this driver? And to handle things like many-to-many relationships with composite primary keys etc?
I see there is an existing library for composite keys in Eloquent in general, https://github.com/thiagoprz/eloquent-composite-key - is that compatible with this driver perhaps?