You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, in my project, there is a many-to-many relationship between User and Project. To manage this, I am using an intermediate table called UserProject to associate User and Project. Here is the structure of UserProject:
typeUserProjectstruct {
gorm.ModelUserIDuint`gorm:"primaryKey"`ProjectIDuint`gorm:"primaryKey"`Rolestring`gorm:"type:varchar(32);comment:User's role in the project (admin, user)"`
}
Now, users can create tasks in a given project (task belongs to user and project). Here is the design of my Task table:
typeAIJobstruct {
gorm.ModelNamestring`gorm:"type:varchar(128);not null;comment:Name of the job"`UserIDuintProjectIDuintUserProjectUserProject`gorm:"foreignKey:UserID,ProjectID"`TaskTypestring`gorm:"type:varchar(128);not null"`
}
However, during migration, it keeps saying that I have not set the appropriate foreign keys. What should I do?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, in my project, there is a many-to-many relationship between
User
andProject
. To manage this, I am using an intermediate table calledUserProject
to associateUser
andProject
. Here is the structure ofUserProject
:Now, users can create tasks in a given project (task belongs to user and project). Here is the design of my Task table:
However, during migration, it keeps saying that I have not set the appropriate foreign keys. What should I do?
Beta Was this translation helpful? Give feedback.
All reactions