New table: actor.usr_saved_search
[working/Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0351.schema.usr_saved_search.sql
1 BEGIN;
2
3 INSERT INTO config.upgrade_log (version) VALUES ('0351'); -- Scott McKellar
4
5 CREATE TABLE actor.usr_saved_search (
6     id              SERIAL          PRIMARY KEY,
7         owner           INT             NOT NULL REFERENCES actor.usr (id)
8                                         ON DELETE CASCADE
9                                         DEFERRABLE INITIALLY DEFERRED,
10         name            TEXT            NOT NULL,
11         create_date     TIMESTAMPTZ     NOT NULL DEFAULT now(),
12         query_text      TEXT            NOT NULL,
13         query_type      TEXT            NOT NULL
14                                         CONSTRAINT valid_query_text CHECK (
15                                         query_type IN ( 'URL' )) DEFAULT 'URL',
16                                         -- we may add other types someday
17         target          TEXT            NOT NULL
18                                         CONSTRAINT valid_target CHECK (
19                                         target IN ( 'record', 'metarecord', 'callnumber' )),
20         CONSTRAINT name_once_per_user UNIQUE (owner, name)
21 );
22
23 COMMIT;