hs.hsadmin.ng/src/main/resources/db/changelog/0-base/011-table-schema-and-name.sql
Michael Hoennig f33a3a2df7 introduce-separate-database-schemas-hs-booking-and-hosting (#106)
Co-authored-by: Michael Hoennig <michael@hoennig.de>
Reviewed-on: #106
Reviewed-by: Marc Sandlus <marc.sandlus@hostsharing.net>
2024-09-23 10:52:37 +02:00

22 lines
774 B
PL/PgSQL

--liquibase formatted sql
-- ============================================================================
--changeset michael.hoennig:base-COMBINE-TABLE-SCHEMA-AND-NAME endDelimiter:--//
-- ----------------------------------------------------------------------------
create or replace function base.combine_table_schema_and_name(tableSchema name, tableName name)
returns text
language plpgsql as $$
begin
assert LEFT(tableSchema, 1) <> '"', 'tableSchema must not start with "';
assert LEFT(tableName, 1) <> '"', 'tableName must not start with "';
if tableSchema is null or tableSchema = 'public' or tableSchema = '' then
return tableName::text;
else
return tableSchema::text || '.' || tableName::text;
end if;
end; $$;
--//