2023-01-27 23:29:47 -05:00
|
|
|
/* init_order = 1 */
|
|
|
|
|
2021-11-30 22:41:16 -05:00
|
|
|
create table resources (
|
2023-01-19 07:27:01 -05:00
|
|
|
tenant_id varchar(21) not null
|
|
|
|
references tenants (id) on update cascade on delete cascade,
|
|
|
|
id varchar(21) not null,
|
|
|
|
name text not null,
|
2023-01-27 23:29:47 -05:00
|
|
|
indicator text not null, /* resource indicator also used as audience */
|
2023-01-19 07:27:01 -05:00
|
|
|
access_token_ttl bigint not null default(3600), /* expiration value in seconds, default is 1h */
|
|
|
|
primary key (id),
|
|
|
|
constraint resources__indicator
|
|
|
|
unique (tenant_id, indicator)
|
2022-02-15 03:13:41 -05:00
|
|
|
);
|
|
|
|
|
2023-01-19 07:27:01 -05:00
|
|
|
create index resources__id
|
2023-01-27 23:29:47 -05:00
|
|
|
on resources (tenant_id, id);
|
2023-01-28 06:26:29 -05:00
|
|
|
|
|
|
|
create trigger set_tenant_id before insert on resources
|
|
|
|
for each row execute procedure set_tenant_id();
|