simple setup for reporter thingy
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 21 Sep 2005 15:26:13 +0000 (15:26 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 21 Sep 2005 15:26:13 +0000 (15:26 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1843 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/reporter/config.sql [new file with mode: 0644]

diff --git a/Open-ILS/src/reporter/config.sql b/Open-ILS/src/reporter/config.sql
new file mode 100644 (file)
index 0000000..5211692
--- /dev/null
@@ -0,0 +1,47 @@
+DROP SCEMA reporter CASCADE;
+CREATE SCHEMA reporter;
+
+BEGIN;
+
+CREATE TABLE reporter.stage2 (
+       id              serial                          primary key,
+       stage1          text                            not null,
+       filename        text                            not null,
+       owner           int                             not null,
+       pub             bool                            not null
+                                                       default false,
+       create_date     timestamp with time zone        not null
+                                                       default now(),
+       edit_date       timestamp with time zone        not null
+                                                       default now()
+);
+
+CREATE OR REPLACE FUNCTION reporter.force_edit_date_update () RETURNS TRIGGER AS $$
+       BEGIN
+               NEW.edit_date = NOW();
+               RETURN NEW;
+       END;
+$$ LANGUAGE PLPGSQL;
+
+CREATE TRIGGER force_edit_date_update_trig
+       BEFORE UPDATE ON reporter.stage2
+       FOR EACH ROW
+       EXECUTE PROCEDURE reporter.force_edit_date_update ();
+
+CREATE TABLE reporter.stage3 (
+       id              serial                          primary key,
+       stage2          int                             not null 
+                                                       references reporter.stage2 (id)
+                                                               on delete restrict
+                                                               deferrable
+                                                               initially deferred,
+       filename        text                            not null,
+       owner           int                             not null,
+       pub             bool                            not null
+                                                       default false,
+       create_date     timestamp with time zone        not null
+                                                       default now()
+);
+
+COMMIT;
+