JBKahn / django-sharding

A sharding library for Django
BSD 3-Clause "New" or "Revised" License
222 stars 47 forks source link

Polymorphic relationships within sharded databases (contenttypes framework) #92

Open Syntaf opened 3 years ago

Syntaf commented 3 years ago

Hey all 👋

Has anyone managed to get Polymorphic relationships functional on sharded databases? When trying to do so myself, I found that I was unable to define such relationships because the contenttypes framework only persists information on the default database.

I imagine a solution would involve persisting the contenttypes tables across every shard, but haven't had much luck so far accomplishing this myself.

Any tips or recommendations would be awesome, thanks!

JBKahn commented 3 years ago

Sorry, I haven't been working on this repo much since I haven't used much in the way of Django/Python for work over the past year since switching jobs.

My next goal was going to be working on adding some basic functionality for multi-db support directly in Django for stuff like that. I think it's possible to monkey-patch but you'd need to override that in a few places to get it to work like that.

JBKahn commented 3 years ago

It may be easier to fix this in Django than to try to hack it.

Syntaf commented 3 years ago

Thanks for the reply @JBKahn - I agree that a solution would probably fall into Django rather than this library since the issue stems from the contenttypes framework.

Did you have the same solution in mind that I mentioned above? Just looking to pick your brain but no worries if you're too busy doing other things 👍 - this is something that would be great to support with sharding and I'm interested in looking into it further.