0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00
logto/packages/schemas/tables/application_user_consent_organizations.sql
simeng-li de37e71239
feat(schemas): add new application user consent orgs table (#5235)
add new application user consent organizations table
2024-01-16 10:47:59 +08:00

16 lines
875 B
SQL

/* init_order = 3 */
/** The relations between applications, users and organizations. A relation means that a user has consented to an application to access data in an organization. */
create table application_user_consent_organizations (
tenant_id varchar(21) not null
references tenants (id) on update cascade on delete cascade,
application_id varchar(21) not null
references applications (id) on update cascade on delete cascade,
organization_id varchar(21) not null,
user_id varchar(21) not null,
primary key (tenant_id, application_id, organization_id, user_id),
/** User's consent to an application should be synchronized with the user's membership in the organization. */
foreign key (tenant_id, organization_id, user_id)
references organization_user_relations (tenant_id, organization_id, user_id)
on update cascade on delete cascade
)