397 BRaw
| 1 | -- Links a user to an organisation with a role. The unique pair stops a user holding |
| 2 | -- two roles in the same organisation. |
| 3 | create table memberships ( |
| 4 | id text primary key, |
| 5 | org_id text not null references orgs (id), |
| 6 | user_id text not null references users (id), |
| 7 | role text not null, |
| 8 | unique (org_id, user_id) |
| 9 | ); |
| 10 | |
| 11 | create index memberships_user_id on memberships (user_id); |