FriendsOfFlarum / gamification

Add upvotes, downvotes, and ranks to your Flarum Community
https://discuss.flarum.org/d/20671-friendsofflarum-gamification
MIT License
36 stars 17 forks source link

No foreign key between post_votes and users table #87

Closed rob006 closed 1 year ago

rob006 commented 2 years ago

Is it intentional that there are no FK between these two tables? Right now if user gets deleted his votes are preserved and I'm not sure if it is expected behavior.

clarkwinkelmann commented 2 years ago

I think this might be intentional.

The hotness of discussions is calculated from that table, so deleting a user would cause a discussion to drop in the hotness ranking.

https://github.com/FriendsOfFlarum/gamification/blob/54db432e0e2162d11b4e579cb0567c47aad13aea/src/Vote.php#L77-L82

We should probably clarify that it is the intended behavior in the source code if we are ok with this.

rob006 commented 2 years ago

I think that there should be FK with SET NULL for ON DELETE - it will be clear that this is intended behavior. Right now leaving orphaned IDs in user_id looks like an oversight.

clarkwinkelmann commented 2 years ago

That makes sense :+1:

imorland commented 1 year ago

Fixed in https://github.com/FriendsOfFlarum/gamification/pull/93