Mercurial > gemma
comparison schema/gemma.sql @ 4043:fbd7c012f10c historization_ng
Merged
author | Sascha Wilde <wilde@intevation.de> |
---|---|
date | Wed, 24 Jul 2019 11:16:38 +0200 |
parents | 3fcb95a07948 4f2f34f5d14d |
children | f42f7f7eb81f |
comparison
equal
deleted
inserted
replaced
4042:9f6a6b8ad965 | 4043:fbd7c012f10c |
---|---|
900 CREATE INDEX kind_idx ON import_logs(kind) | 900 CREATE INDEX kind_idx ON import_logs(kind) |
901 | 901 |
902 CREATE TABLE track_imports ( | 902 CREATE TABLE track_imports ( |
903 import_id int NOT NULL REFERENCES imports(id) | 903 import_id int NOT NULL REFERENCES imports(id) |
904 ON DELETE CASCADE, | 904 ON DELETE CASCADE, |
905 deletion bool NOT NULL DEFAULT false, | |
905 relation regclass NOT NULL, | 906 relation regclass NOT NULL, |
906 key int NOT NULL, | 907 key int NOT NULL, |
907 UNIQUE (relation, key) | 908 UNIQUE (relation, key) |
908 ) | 909 ) |
909 ; | 910 ; |
912 $$ | 913 $$ |
913 DECLARE | 914 DECLARE |
914 tmp RECORD; | 915 tmp RECORD; |
915 BEGIN | 916 BEGIN |
916 FOR tmp IN | 917 FOR tmp IN |
917 SELECT * FROM import.track_imports WHERE import_id = imp_id | 918 SELECT * FROM import.track_imports WHERE import_id = imp_id AND NOT deletion |
918 LOOP | 919 LOOP |
919 EXECUTE format('DELETE FROM %s WHERE id = $1', tmp.relation) USING tmp.key; | 920 EXECUTE format('DELETE FROM %s WHERE id = $1', tmp.relation) USING tmp.key; |
920 END LOOP; | 921 END LOOP; |
921 END; | |
922 $$ | |
923 LANGUAGE plpgsql; | |
924 | |
925 CREATE FUNCTION import.del_import() RETURNS trigger AS | |
926 $$ | |
927 BEGIN | |
928 EXECUTE format('DELETE FROM %s WHERE id = $1', OLD.relation) USING OLD.key; | |
929 RETURN NULL; | |
930 END; | 922 END; |
931 $$ | 923 $$ |
932 LANGUAGE plpgsql; | 924 LANGUAGE plpgsql; |
933 | 925 |
934 CREATE SCHEMA caching | 926 CREATE SCHEMA caching |