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

17 lines
875 B
MySQL
Raw Normal View History

/* 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
)