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
- [Solved] Appwrite project paused
I have github student account. The auth has been paused however the database is working fine. I cant see any option to resume from my console panel. It is just ...
- MongoDb Database Breaks integer[] & bigi...
I've got a table with the below column created. When I try to insert the value `[-3408048000]` into it, the dart sdk cloud function call is successful (no error...
- 1.9.6 Console handles all array columns ...
When creating or updating a row in the appwrite 1.9.6 web console, the form treats all list columns as a type string. Even if the column is a list of booleans, ...