Skip to content

Commit

Permalink
feat(schemas): add table application_user_consent_organization_resour…
Browse files Browse the repository at this point in the history
…ce_scopes
  • Loading branch information
wangsijie committed Apr 28, 2024
1 parent b80934a commit a156a9c
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 application_user_consent_organization_resource_scopes (
tenant_id varchar(21) not null
references tenants (id) on update cascade on delete cascade,
/** The globally unique identifier of the application. */
application_id varchar(21) not null
references applications (id) on update cascade on delete cascade,
/** The globally unique identifier of the resource scope. */
scope_id varchar(21) not null
references scopes (id) on update cascade on delete cascade,
primary key (application_id, scope_id)
);
`);
await applyTableRls(pool, 'application_user_consent_organization_resource_scopes');
},
down: async (pool) => {
await dropTableRls(pool, 'application_user_consent_organization_resource_scopes');
await pool.query(sql`
drop table application_user_consent_organization_resource_scopes
`);
},
};

export default alteration;
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* init_order = 3 */

/** The resource scopes (permissions) assigned to an application's consent request. */
create table application_user_consent_organization_resource_scopes (
tenant_id varchar(21) not null
references tenants (id) on update cascade on delete cascade,
/** The globally unique identifier of the application. */
application_id varchar(21) not null
references applications (id) on update cascade on delete cascade,
/** The globally unique identifier of the resource scope. */
scope_id varchar(21) not null
references scopes (id) on update cascade on delete cascade,
primary key (application_id, scope_id)
);

0 comments on commit a156a9c

Please sign in to comment.