comparison schema/gemma.sql @ 1012:875b0a9a3c92

Fixed schema definition of import queue.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 23 Oct 2018 11:32:47 +0200
parents 75e65599ea52
children 72cad6277e3a
comparison
equal deleted inserted replaced
1011:9d4af4b1c5c8 1012:875b0a9a3c92
498 OR forecast_generation_time IS NOT NULL), 498 OR forecast_generation_time IS NOT NULL),
499 value_lifetime timestamp with time zone, 499 value_lifetime timestamp with time zone,
500 CHECK(measure_type = 'minimum guaranteed' 500 CHECK(measure_type = 'minimum guaranteed'
501 OR value_lifetime IS NOT NULL) 501 OR value_lifetime IS NOT NULL)
502 ) 502 )
503
504 --
505 -- Import queue and respective logging
506 --
507 CREATE TYPE import_state AS ENUM ('queued', 'running', 'successful', 'failed')
508
509 CREATE TABLE imports (
510 id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
511 state import_state NOT NULL DEFAULT 'queued',
512 enqueued timestamp NOT NULL DEFAULT now(),
513 kind varchar NOT NULL,
514 username varchar NOT NULL
515 REFERENCES internal.user_profiles(username)
516 ON DELETE CASCADE ON UPDATE CASCADE,
517 data TEXT
518 )
519
520 CREATE INDEX enqueued_idx ON imports(enqueued, state)
521
522 CREATE TYPE log_type AS ENUM ('info', 'warn', 'error')
523
524 CREATE TABLE import_logs (
525 import_id int NOT NULL REFERENCES imports(id),
526 time timestamp NOT NULL DEFAULT now(),
527 kind log_type NOT NULL DEFAULT 'info',
528 msg TEXT NOT NULL
529 )
530 ; 503 ;
531 504
505 --
506 -- Import queue and respective logging
507 --
508 CREATE TYPE waterway.import_state AS ENUM ('queued', 'running', 'successful', 'failed');
509
510 CREATE TABLE waterway.imports (
511 id int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
512 state waterway.import_state NOT NULL DEFAULT 'queued',
513 enqueued timestamp NOT NULL DEFAULT now(),
514 kind varchar NOT NULL,
515 username varchar NOT NULL
516 REFERENCES internal.user_profiles(username)
517 ON DELETE CASCADE ON UPDATE CASCADE,
518 data TEXT
519 );
520
521 CREATE INDEX enqueued_idx ON waterway.imports(enqueued, state);
522
523 CREATE TYPE waterway.log_type AS ENUM ('info', 'warn', 'error');
524
525 CREATE TABLE waterway.import_logs (
526 import_id int NOT NULL REFERENCES waterway.imports(id),
527 time timestamp NOT NULL DEFAULT now(),
528 kind waterway.log_type NOT NULL DEFAULT 'info',
529 msg TEXT NOT NULL
530 );
531
532 COMMIT; 532 COMMIT;