Dynamic schema selection allows to deploy same application code into separate schemas
This (probably) allows to solve the issue related to deploying same application multiple times on same HAF instance. Good example is a balance tracker, which could be deployed together with haf_be
like also as standalone installation. Right now, because balance_tracker code statically defines its deployment schema it is impossible.
Changing search_path
property at code deployment time and using schemaless notation on object declarations allows to create given objects inside target schema dynamically - each time into schema pointed by search_path property.
--- separate schema creation code:
create schema my_test authorization haf_admin;
--- separate schema selection code:
set search_path=my_test;
--- separate object definition code:
CREATE OR REPLACE FUNCTION some_fun()
RETURNS boolean
LANGUAGE 'plpgsql'
AS $BODY$
BEGIN
RETURN false;
END
$BODY$;
Finally above could be done as:
psql -c 'set search_path=my_test;' -f common_app_defs.sql
We need further investigation how to simple force correct resolution of identifiers (i.e. inside function definition) to actual schema. Maybe just setting search_path
at roles specific to the application using given code would be sufficient.