mirror of
https://github.com/logto-io/logto.git
synced 2025-03-31 22:51:25 -05:00
fix(schemas): explicitly set search path (#6101)
This commit is contained in:
parent
bede80e2f5
commit
d7d2af68a9
3 changed files with 27 additions and 2 deletions
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* In Logto Cloud, we have multiple schemas and the default search behavior will be problematic.
|
||||
* This alteration script will fix it by setting the search path to public for the functions.
|
||||
*/
|
||||
|
||||
import { sql } from '@silverhand/slonik';
|
||||
|
||||
import type { AlterationScript } from '../lib/types/alteration.js';
|
||||
|
||||
const alteration: AlterationScript = {
|
||||
up: async (pool) => {
|
||||
await pool.query(sql`
|
||||
alter function check_application_type set search_path = public;
|
||||
alter function check_organization_role_type set search_path = public;
|
||||
`);
|
||||
},
|
||||
down: async (pool) => {
|
||||
await pool.query(sql`
|
||||
alter function check_application_type reset search_path;
|
||||
alter function check_organization_role_type reset search_path;
|
||||
`);
|
||||
},
|
||||
};
|
||||
|
||||
export default alteration;
|
|
@ -37,4 +37,4 @@ create unique index applications__protected_app_metadata_custom_domain
|
|||
create function check_application_type(application_id varchar(21), target_type application_type) returns boolean as
|
||||
$$ begin
|
||||
return (select type from applications where id = application_id) = target_type;
|
||||
end; $$ language plpgsql;
|
||||
end; $$ language plpgsql set search_path = public;
|
||||
|
|
|
@ -23,4 +23,4 @@ create index organization_roles__id
|
|||
create function check_organization_role_type(role_id varchar(21), target_type role_type) returns boolean as
|
||||
$$ begin
|
||||
return (select type from organization_roles where id = role_id) = target_type;
|
||||
end; $$ language plpgsql;
|
||||
end; $$ language plpgsql set search_path = public;
|
||||
|
|
Loading…
Add table
Reference in a new issue