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
- IMPORTANT! SOC-2 Request Failing
Issue requesting SOC-2. If tried other/private browser as well as filling in optional fields.
- Can you suppress row $meta data?
When using listRows with a 'select' query to limit the response [for performance], I'm still getting extra columns (eg. `$id`, `$sequence`, `$createdAt`, `$upda...
- CLI - get Database Totals
Is there a way with the Appwrite CLI to get table row totals (count)❓