lonnieezell / myth-auth

One-stop Auth package for CodeIgniter 4
MIT License
634 stars 207 forks source link

fix(migrations): set keys as primary for associative tables #480

Closed yassinedoghri closed 2 years ago

yassinedoghri commented 2 years ago

Hello! I stumbled onto this as I was trying to seed MythAuth's associative tables, and having a lot of duplicates 😅

The keys for the auth_groups_permissions, auth_groups_users and auth_users_permissions should be both foreign and primary as they should be unique and they identify a given row.

--> It doesn't make sense to have a group given the same permission twice or more, nor to have a user in the same group multiple times, and so on…

That being said, I've set them as primary in the migration file. Hope it helps!

MGatner commented 2 years ago

I'm always torn on how to handle migration issues: update the faulty migration file, or create a new one? The former only fixes issues for new instances, but is much cleaner. I'll let @lonnieezell make the call on this one.

lonnieezell commented 2 years ago

Please create a new migration to handle these. It works for everyone that way.

MGatner commented 2 years ago

@yassinedoghri I'm closing this since it will soon be a conflict, but I do believe you are correct. Would you be willing to resubmit as a new migration?

yassinedoghri commented 2 years ago

@yassinedoghri I'm closing this since it will soon be a conflict, but I do believe you are correct. Would you be willing to resubmit as a new migration?

Hey @MGatner I completely forgot about this PR, sorry... I'll try my best in working on the issue again!