Giter Site home page Giter Site logo

Comments (4)

 avatar commented on June 17, 2024

Whatever is most common, I'm fine with.

from laravel-5-generators-extended.

Mythos avatar Mythos commented on June 17, 2024

IMHO a primary key out of FK1 and FK2 would be best.
Like users_groups: PRIMARY(user_id, group_id)
At the moment you can add the same entry multiple times which does not make sense to me.

from laravel-5-generators-extended.

etenzy avatar etenzy commented on June 17, 2024

Thanks to @vinkla for commiting.
Currently i don't have the ability for pushing code up to github...

I've testet different cases:

PRIMARY(user_id, group_id) will end up with:
'Illuminate\Database\QueryException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'xxx-xxx' for key 'PRIMARY

UNIQUE(user_id, group_id) results similar...

Without checking the relation before inserting you will have two options:

  1. Use an incremented id field as primary key & no UNIQUE(user_id, group_id) key and get along with duplicates
  2. try/catch every save/attach on every many to many relation...

so...
The most open way is adding an incremented id field as primary key as default.

If you want to avoid duplicates just add an UNIQUE key and try/catch everything

from laravel-5-generators-extended.

tabacitu avatar tabacitu commented on June 17, 2024

@etenzy are you still using the package? If so, let me know what you think we should do about this, today, in 2020. I'm working on v2 #170 and would love to put this issue to rest. The package is finally getting the attention it deserves, no better time to have this if you still want it 😄

Cheers!

from laravel-5-generators-extended.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.