File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed
Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change 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 applications__include_type_is_third_party
9+ on applications (tenant_id) include (type, is_third_party);
10+ ` ) ;
11+
12+ // Update table statistics to help query planner use the new index efficiently
13+ await pool . query ( sql `
14+ analyze applications;
15+ ` ) ;
16+
17+ await pool . query ( sql `
18+ create index roles__include_type_name
19+ on roles (tenant_id) include (type, name);
20+ ` ) ;
21+
22+ // Update table statistics to help query planner use the new index efficiently
23+ await pool . query ( sql `
24+ analyze roles;
25+ ` ) ;
26+ } ,
27+ down : async ( pool ) => {
28+ await pool . query ( sql `
29+ drop index if exists applications__include_type_is_third_party;
30+ ` ) ;
31+
32+ await pool . query ( sql `
33+ drop index if exists roles__include_type_name;
34+ ` ) ;
35+ } ,
36+ } ;
37+
38+ export default alteration ;
Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ create table applications (
2323create index applications__id
2424 on applications (tenant_id, id);
2525
26+ create index applications__include_type_is_third_party
27+ on applications (tenant_id) include (type, is_third_party);
28+
2629create index applications__is_third_party
2730 on applications (tenant_id, is_third_party);
2831
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ create table roles (
1919create index roles__id
2020 on roles (tenant_id, id);
2121
22+ create index roles__include_type_name
23+ on roles (tenant_id) include (type, name);
24+
2225create index roles__type
2326 on roles (tenant_id, type);
2427
You can’t perform that action at this time.
0 commit comments