luckyframework / website

The Lucky website
https://luckyframework.org
37 stars 66 forks source link

polymorphic association docs don't explain database structure #611

Open matthewmcgarvey opened 3 years ago

matthewmcgarvey commented 3 years ago

https://luckyframework.org/guides/database/models#polymorphic-associations

Coming from rails, I was reading the guide assuming the table had a assoc_type and assoc_id columns but the way Lucky accomplishes the polymorphic relationship is by having a nilable column for each different type and handles the polymorphism at the code layer.

A better explanation of the database layout would make it more clear.

Maybe even bonus points if we lay out how why Lucky can't do polymorphic associations like Rails does since we are statically typed.

stephendolan commented 3 years ago

Wow, yeah I've read these docs but the fact that you needed one foreign key per possible association will make it pretty much impossible to take an ActionText or ActiveStorage approach for libraries in the future.

I actually really dislike how those libraries structure the DB so that doesn't bum me out, but it's a great catch to address that up front, loud and clear.