mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
feat(schemas): add organization role resource scope relation
This commit is contained in:
parent
9bf9f07f17
commit
12f464c09b
2 changed files with 42 additions and 0 deletions
|
@ -0,0 +1,30 @@
|
|||
import { sql } from '@silverhand/slonik';
|
||||
|
||||
import type { AlterationScript } from '../lib/types/alteration.js';
|
||||
|
||||
import { applyTableRls, dropTableRls } from './utils/1704934999-tables.js';
|
||||
|
||||
const alteration: AlterationScript = {
|
||||
up: async (pool) => {
|
||||
await pool.query(sql`
|
||||
create table organization_role_resource_scope_relations (
|
||||
tenant_id varchar(21) not null
|
||||
references tenants (id) on update cascade on delete cascade,
|
||||
organization_role_id varchar(21) not null
|
||||
references organization_roles (id) on update cascade on delete cascade,
|
||||
resource_scope_id varchar(21) not null
|
||||
references scopes (id) on update cascade on delete cascade,
|
||||
primary key (tenant_id, organization_role_id, resource_scope_id)
|
||||
);
|
||||
`);
|
||||
await applyTableRls(pool, 'organization_role_resource_scope_relations');
|
||||
},
|
||||
down: async (pool) => {
|
||||
await dropTableRls(pool, 'organization_role_resource_scope_relations');
|
||||
await pool.query(sql`
|
||||
drop table organization_role_resource_scope_relations
|
||||
`);
|
||||
},
|
||||
};
|
||||
|
||||
export default alteration;
|
|
@ -0,0 +1,12 @@
|
|||
/* init_order = 3 */
|
||||
|
||||
/** The relations between organization roles and resource scopes (normal scopes). It indicates which resource scopes are available to which organization roles. */
|
||||
create table organization_role_resource_scope_relations (
|
||||
tenant_id varchar(21) not null
|
||||
references tenants (id) on update cascade on delete cascade,
|
||||
organization_role_id varchar(21) not null
|
||||
references organization_roles (id) on update cascade on delete cascade,
|
||||
resource_scope_id varchar(21) not null
|
||||
references scopes (id) on update cascade on delete cascade,
|
||||
primary key (tenant_id, organization_role_id, resource_scope_id)
|
||||
);
|
Loading…
Reference in a new issue