Add three more tables to the query schema: record_column, select_item,
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 2 Dec 2009 16:55:53 +0000 (16:55 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 2 Dec 2009 16:55:53 +0000 (16:55 +0000)
and order_by_item.

M    Open-ILS/src/sql/Pg/002.schema.config.sql
A    Open-ILS/src/sql/Pg/upgrade/0102.schema.query-col-sel-order.sql
M    Open-ILS/examples/fm_IDL.xml

git-svn-id: svn://svn.open-ils.org/ILS/trunk@15059 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/0102.schema.query-col-sel-order.sql [new file with mode: 0644]

index 3682e7c..1597a44 100644 (file)
@@ -5508,6 +5508,54 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
                </permacrud>
        </class>
 
+       <class id="qrc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::record_column" oils_persist:tablename="query.record_column" reporter:label="Record Column">
+               <fields oils_persist:primary="id" oils_persist:sequence="record_column_id_seq">
+                       <field reporter:label="Record Column ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="From Relation ID" name="from_relation" reporter:datatype="link"/>
+                       <field reporter:label="Sequence Number" name="seq_no" reporter:datatype="int"/>
+                       <field reporter:label="Column Name" name="column_name" reporter:datatype="text"/>
+                       <field reporter:label="Column Type" name="column_type" reporter:datatype="link"/>
+               </fields>
+               <links>
+                       <link field="from_relation" reltype="has_a" key="id" map="" class="qfr"/>
+                       <link field="column_type" reltype="has_a" key="id" map="" class="qdt"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+               </permacrud>
+       </class>
+
+       <class id="qsi" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::select_item" oils_persist:tablename="query.select_item" reporter:label="Select Item">
+               <fields oils_persist:primary="id" oils_persist:sequence="select_item_id_seq">
+                       <field reporter:label="Select Item ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Stored Query ID" name="stored_query" reporter:datatype="link"/>
+                       <field reporter:label="Sequence Number" name="seq_no" reporter:datatype="int"/>
+                       <field reporter:label="Expression" name="expression" reporter:datatype="link"/>
+                       <field reporter:label="Column Alias" name="column_alias" reporter:datatype="text"/>
+                       <field reporter:label="Is Grouped By" name="grouped_by" reporter:datatype="bool"/>
+               </fields>
+               <links>
+                       <link field="stored_query" reltype="has_a" key="id" map="" class="qsq"/>
+                       <link field="expression" reltype="has_a" key="id" map="" class="qxp"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+               </permacrud>
+       </class>
+
+       <class id="qobi" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::order_by_item" oils_persist:tablename="query.order_by_item" reporter:label="Order By Item">
+               <fields oils_persist:primary="id" oils_persist:sequence="order_by_item_id_seq">
+                       <field reporter:label="Order By Item ID" name="id" reporter:datatype="id"/>
+                       <field reporter:label="Stored Query ID" name="stored_query" reporter:datatype="link"/>
+                       <field reporter:label="Sequence Number" name="seq_no" reporter:datatype="int"/>
+                       <field reporter:label="Expression" name="expression" reporter:datatype="link"/>
+               </fields>
+               <links>
+                       <link field="stored_query" reltype="has_a" key="id" map="" class="qsq"/>
+                       <link field="expression" reltype="has_a" key="id" map="" class="qxp"/>
+               </links>
+               <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+               </permacrud>
+       </class>
+
        <!-- ********************************************************************************************************************* -->
        <!-- What follows is a set of example extensions that are useful for PINES.  Comment out or remove if you don't want them. -->
        <!-- ********************************************************************************************************************* -->
index 8d04671..9842d8a 100644 (file)
@@ -51,7 +51,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0101'); -- berick
+INSERT INTO config.upgrade_log (version) VALUES ('0102'); -- Scott McKellar
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/0102.schema.query-col-sel-order.sql b/Open-ILS/src/sql/Pg/upgrade/0102.schema.query-col-sel-order.sql
new file mode 100644 (file)
index 0000000..d21f858
--- /dev/null
@@ -0,0 +1,45 @@
+-- Script to create the query schema and the tables therein
+
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0102'); -- Scott McKellar
+
+CREATE TABLE query.record_column (
+       id            SERIAL            PRIMARY KEY,
+       from_relation INT               NOT NULL REFERENCES query.from_relation
+                                       ON DELETE CASCADE
+                                       DEFERRABLE INITIALLY DEFERRED,
+       seq_no        INT               NOT NULL,
+       column_name   TEXT              NOT NULL,
+       column_type   INT               NOT NULL REFERENCES query.datatype
+                                       ON DELETE CASCADE
+                                                                       DEFERRABLE INITIALLY DEFERRED,
+       CONSTRAINT column_sequence UNIQUE (from_relation, seq_no)
+);
+
+CREATE TABLE query.select_item (
+       id               SERIAL         PRIMARY KEY,
+       stored_query     INT            NOT NULL REFERENCES query.stored_query
+                                       ON DELETE CASCADE
+                                       DEFERRABLE INITIALLY DEFERRED,
+       seq_no           INT            NOT NULL,
+       expression       INT            NOT NULL REFERENCES query.expression
+                                       DEFERRABLE INITIALLY DEFERRED,
+       column_alias     TEXT,
+       grouped_by       BOOL           NOT NULL DEFAULT FALSE,
+       CONSTRAINT select_sequence UNIQUE( stored_query, seq_no )
+);
+
+CREATE TABLE query.order_by_item (
+       id               SERIAL         PRIMARY KEY,
+       stored_query     INT            NOT NULL REFERENCES query.stored_query
+                                       ON DELETE CASCADE
+                                       DEFERRABLE INITIALLY DEFERRED,
+       seq_no           INT            NOT NULL,
+       expression       INT            NOT NULL REFERENCES query.expression
+                                       ON DELETE CASCADE
+                                       DEFERRABLE INITIALLY DEFERRED,
+       CONSTRAINT order_by_sequence UNIQUE( stored_query, seq_no )
+);
+
+COMMIT;