Skip to content

Commit 3341a6d

Browse files
authored
feat(schemas): add index for organization role type (#7946)
1 parent 73c7c28 commit 3341a6d

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { sql } from '@silverhand/slonik';
2+
3+
import type { AlterationScript } from '../lib/types/alteration.js';
4+
5+
const alteration: AlterationScript = {
6+
up: async (pool) => {
7+
await pool.query(sql`
8+
create index organization_roles__type
9+
on organization_roles (tenant_id, type);
10+
`);
11+
},
12+
down: async (pool) => {
13+
await pool.query(sql`
14+
drop index organization_roles__type;
15+
`);
16+
},
17+
};
18+
19+
export default alteration;

packages/schemas/tables/organization_roles.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ create table organization_roles (
2020
create index organization_roles__id
2121
on organization_roles (tenant_id, id);
2222

23+
create index organization_roles__type
24+
on organization_roles (tenant_id, type);
25+
2326
create function check_organization_role_type(role_id varchar(21), target_type role_type) returns boolean as
2427
$$ begin
2528
return (select type from organization_roles where id = role_id) = target_type;

0 commit comments

Comments
 (0)