update db schema
This commit is contained in:
1 parent
11d44ccfd3
commit
0908e51791
4 files changed
+109
-24
No files matched your search
@@ -1,3 +1,24 @@
|
||||
CREATE OR REPLACE FUNCTION "f_updatedAt"()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW."updatedAt" = now();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ language 'plpgsql';
|
||||
|
||||
CREATE FUNCTION array_distinct(anyarray) RETURNS anyarray AS $f$
|
||||
SELECT array_agg(DISTINCT x) FROM unnest($1) t(x);
|
||||
$f$ LANGUAGE SQL IMMUTABLE;
|
||||
|
||||
CREATE OR REPLACE FUNCTION normalize_reading (TEXT[]) RETURNS TEXT[] AS
|
||||
$func$
|
||||
DECLARE
|
||||
s TEXT;
|
||||
new_arr TEXT[] := '{}';
|
||||
BEGIN
|
||||
FOREACH s IN ARRAY $1||'{}'::text[] LOOP
|
||||
new_arr := new_arr||ARRAY[split_part(s,'.',1), replace(s,'.','')];
|
||||
END LOOP;
|
||||
RETURN new_arr;
|
||||
END;
|
||||
$func$ LANGUAGE plpgsql IMMUTABLE;
|
||||
Reference in new issue
Block a user