- 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
19 lines
479 B
PL/PgSQL
19 lines
479 B
PL/PgSQL
-- 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';
|