I am encountering an issue with my schedule table, which is derived from a many-to-many relationship between a classes and users table.
User typeorm schema
@ManyToMany(type => UClass, c => c.users, {cascade: true, onDelete: "CASCADE"})
@JoinTable({name: "schedule"})
classes: UClass[]
Class typeorm schema
@ManyToMany(type => User, u => u.classes)
@JoinTable({name: "schedule"})
users: User[]
When attempting to create a user:
{
"username":"a",
...(rest of data)
"classes":[{"id":"f602a286-3df1-4912-9165-2375b5e45bdd"}]
}
An error is triggered displaying:
QueryFailedError: insert or update on table \"schedule\" violates foreign key constraint \"FK_d796103491cf0bae197dda59477\
I am uncertain why this foreign key error is occurring since both the provided user and class ids are valid. Any assistance would be greatly appreciated.