Hey folks. Consider the code below. It represents an explicit many to many relationship. The UserCommunicationChannelLink contains attributes which do not belong neither in User nor in CommunicationChannel. Consequently, I create a Link table, with manyToOne relations, meaning
the foreignKey are on the many side (the link table).
const collectionId = 'UserCommunicationChannelLink'
await db.createRelationshipAttribute(
db.id,
collectionID,
'User',
'manyToOne',
false,
'user',
undefined,
'restrict',
);
await db.createRelationshipAttribute(
db.id,
collectionID,
'CommunicationChannel',
'manyToOne',
false,
'channel',
undefined,
'restrict',
);
The idea is that a User can have many CommunicationChannels and, each CommunicationChannel may exist in more than one user. However, each pair of <userId, communicationChannelid> must be unique in the Link table.
When I execute this migration, I get a failure on createRelationshipAttribute;
Error: Cannot create an index for a relationship attribute: user
Is it impossible to create a uniqueness index on two foreign keys?
Recommended threads
- Courtesy limit reset for non-profit migr...
Hi Team! I'm the architect for a 501(c)(3) non-profit project (Aaria's Blue Elephant) and we just hit our Free plan Database Read limit (currently at 164%). Th...
- Does 1.9.0 Self Hosted have MongoDB Atla...
I have been playing with the new 1.9.0 update and I am really excited for the MongoDB support. I wanted to ask though if at the current time Appwrite supports b...
- {"code": 1008, "message": "Invalid Origi...
Nothing has changed in my application or console settings so I'm curious as to what I need to do to fix this. I already have the client registered so I'm not en...