Update core edit_* tables with various fixes

- import script with write to file option
- fix file names for functions
- add generic (non edit tables) for only set date, set uid or combine
- fix edit table edit_language insert data
- all trigger create remove the drop on exists, as in the flow the trigger will never exists
This commit is contained in:
Clemens Schwaighofer
2022-05-31 20:17:32 +09:00
parent 74ba935e96
commit 9949a5ef7f
26 changed files with 1029 additions and 52 deletions

View File

@@ -0,0 +1,18 @@
-- set generic with date and uid combined
-- don't use with set_generic/set_uid together
CREATE OR REPLACE FUNCTION set_generic() RETURNS TRIGGER AS '
DECLARE
random_length INT = 32; -- long for massive data
BEGIN
IF TG_OP = ''INSERT'' THEN
NEW.date_created := ''now'';
IF NEW.uid IS NULL THEN
NEW.uid := random_string(random_length);
END IF;
ELSIF TG_OP = ''UPDATE'' THEN
NEW.date_updated := ''now'';
END IF;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';