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:
@@ -1,6 +1,6 @@
|
||||
-- adds the created or updated date tags
|
||||
|
||||
CREATE OR REPLACE FUNCTION set_generic() RETURNS TRIGGER AS '
|
||||
CREATE OR REPLACE FUNCTION set_date() RETURNS TRIGGER AS '
|
||||
BEGIN
|
||||
IF TG_OP = ''INSERT'' THEN
|
||||
NEW.date_created := ''now'';
|
||||
18
4dev/database/function/set_generic_uid.sql
Normal file
18
4dev/database/function/set_generic_uid.sql
Normal 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';
|
||||
Reference in New Issue
Block a user