changeset 993:6421c51309eb persistent-import-queue

Added tables for importer queue and respective logging.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 22 Oct 2018 13:03:38 +0200
parents a978b2b26a88
children 839526f44f0f
files schema/gemma.sql
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/schema/gemma.sql	Mon Oct 22 11:24:25 2018 +0200
+++ b/schema/gemma.sql	Mon Oct 22 13:03:38 2018 +0200
@@ -500,6 +500,31 @@
         CHECK(measure_type = 'minimum guaranteed'
             OR value_lifetime IS NOT NULL)
     )
+
+    --
+    -- Import queue and respective logging
+    --
+    CREATE TYPE import_state AS ENUM ('queued', 'running', 'successful', 'failed')
+
+    CREATE TABLE imports (
+        id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
+        state import_state NOT NULL DEFAULT 'queued',
+        enqueued timestamp NOT NULL DEFAULT now(),
+        kind  varchar NOT NULL,
+        username varchar NOT NULL
+            REFERENCES internal.user_profiles(username)
+                ON DELETE CASCADE ON UPDATE CASCADE,
+        data TEXT
+    )
+
+    CREATE TYPE log_type AS ENUM ('info', 'warn', 'error')
+
+    CREATE TABLE import_logs (
+        import_id int NOT NULL REFERENCES imports(id),
+        time timestamp NOT NULL DEFAULT now(),
+        kind log_type NOT NULL DEFAULT 'info',
+        msg TEXT NOT NULL
+    )
 ;
 
 COMMIT;