]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/reporter/config.sql
re-enabled client ID caching because it makes a noticable speed difference
[Evergreen.git] / Open-ILS / src / reporter / config.sql
1 DROP SCHEMA reporter CASCADE;
2
3 CREATE SCHEMA reporter;
4
5 BEGIN;
6
7 CREATE TABLE reporter.stage2 (
8         id              serial                          primary key,
9         stage1          text                            not null, 
10         params          text                            not null,
11         owner           int                             not null,
12         pub             bool                            not null
13                                                         default false,
14         create_date     timestamp with time zone        not null
15                                                         default now(),
16         edit_date       timestamp with time zone        not null
17                                                         default now()
18 );
19
20 CREATE OR REPLACE FUNCTION reporter.force_edit_date_update () RETURNS TRIGGER AS $$
21         BEGIN
22                 NEW.edit_date = NOW();
23                 RETURN NEW;
24         END;
25 $$ LANGUAGE PLPGSQL;
26
27 CREATE TRIGGER force_edit_date_update_trig
28         BEFORE UPDATE ON reporter.stage2
29         FOR EACH ROW
30         EXECUTE PROCEDURE reporter.force_edit_date_update ();
31
32 CREATE TABLE reporter.stage3 (
33         id              serial                          primary key,
34         stage2          int                             not null 
35                                                         references reporter.stage2 (id)
36                                                                 on delete restrict
37                                                                 deferrable
38                                                                 initially deferred,
39         params          text                            not null,
40         owner           int                             not null,
41         pub             bool                            not null
42                                                         default false,
43         create_date     timestamp with time zone        not null
44                                                         default now(),
45         runtime timestamp with time zone        default now(),
46         recurrence      interval
47 );
48
49 COMMIT;
50