Files
database/migrations/archive/000.342.sql
T
Rikard BartholfandGitHub ddcbd0afb0 Archive old migrations (#426)
* Archive old migrations

* Fix invalid placement of migrations
2024-10-17 11:19:12 +02:00

25 lines
661 B
PL/PgSQL

-- Revert getsafexml
CREATE OR REPLACE FUNCTION public.getsafexmlpath(val character varying, with_root integer DEFAULT 0)
RETURNS character varying
LANGUAGE plpgsql
AS $function$
BEGIN
IF with_root = 1 THEN
val = regexp_replace(val, '^\w+', 'root');
ELSIF with_root = 2 THEN
val = regexp_replace(val, '^\w+/', '');
END IF;
val = UNACCENT(val);
val = REGEXP_REPLACE(val, '[\., _]', '-', 'g');
val = REPLACE(val, '&', '-'); /* ampersand should always be blank but it gets fixed in below */
val = lower(val);
val = REGEXP_REPLACE(val, '-+', '-', 'g');
val = REGEXP_REPLACE(val, '[^\/\w\-]', '', 'g');
RETURN val;
END; $function$