[open-ils-commits] r15045 - in trunk/Open-ILS: examples src/sql/Pg src/sql/Pg/upgrade (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Nov 30 14:58:18 EST 2009
Author: scottmk
Date: 2009-11-30 14:58:13 -0500 (Mon, 30 Nov 2009)
New Revision: 15045
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0098.schema.sql-stored-query.sql
Modified:
trunk/Open-ILS/examples/fm_IDL.xml
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
Log:
Add two tables to the sql schema: stored_query and query_sequence.
M Open-ILS/src/sql/Pg/002.schema.config.sql
A Open-ILS/src/sql/Pg/upgrade/0098.schema.sql-stored-query.sql
M Open-ILS/examples/fm_IDL.xml
Modified: trunk/Open-ILS/examples/fm_IDL.xml
===================================================================
--- trunk/Open-ILS/examples/fm_IDL.xml 2009-11-30 17:51:05 UTC (rev 15044)
+++ trunk/Open-ILS/examples/fm_IDL.xml 2009-11-30 19:58:13 UTC (rev 15045)
@@ -5333,6 +5333,37 @@
</links>
</class>
+ <class id="qsq" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="sql::stored_query" oils_persist:tablename="sql.stored_query" reporter:label="Stored Query">
+ <fields oils_persist:primary="id" oils_persist:sequence="sql.stored_query_id_seq">
+ <field reporter:label="Query ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Query type" name="type" reporter:datatype="text"/>
+ <field reporter:label="Use ALL" name="use_all" reporter:datatype="bool"/>
+ <field reporter:label="Use DISTINCT" name="use_distinct" reporter:datatype="bool"/>
+ <field reporter:label="FROM Clause" name="from_clause" reporter:datatype="int"/>
+ <field reporter:label="WHERE Clause" name="where_clause" reporter:datatype="int"/>
+ <field reporter:label="HAVING Clause" name="having_clause" reporter:datatype="int"/>
+ </fields>
+ <links>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ </permacrud>
+ </class>
+
+ <class id="qseq" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="sql::query_sequence" oils_persist:tablename="sql.query_sequence" reporter:label="Query Sequence">
+ <fields oils_persist:primary="id" oils_persist:sequence="sql.sql.query_sequence_id_seq">
+ <field reporter:label="Query Seq ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Parent Query" name="parent_query" reporter:datatype="link"/>
+ <field reporter:label="Sequence Number" name="seq_no" reporter:datatype="int"/>
+ <field reporter:label="Child Query" name="child_query" reporter:datatype="link"/>
+ </fields>
+ <links>
+ <link field="parent_query" reltype="has_a" key="id" map="" class="qsq"/>
+ <link field="child_query" reltype="has_a" key="id" map="" class="qsq"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ </permacrud>
+ </class>
+
<class id="qdt" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="sql::datatype" oils_persist:tablename="sql.datatype" reporter:label="Datatype">
<fields oils_persist:primary="id" oils_persist:sequence="sql.datatype_id_seq">
<field reporter:label="Datatype ID" name="id" reporter:datatype="id"/>
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-11-30 17:51:05 UTC (rev 15044)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-11-30 19:58:13 UTC (rev 15045)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0097'); -- Scott McKellar
+INSERT INTO config.upgrade_log (version) VALUES ('0098'); -- Scott McKellar
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0098.schema.sql-stored-query.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0098.schema.sql-stored-query.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0098.schema.sql-stored-query.sql 2009-11-30 19:58:13 UTC (rev 15045)
@@ -0,0 +1,34 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0098'); -- Scott McKellar
+
+CREATE TABLE sql.stored_query (
+ id SERIAL PRIMARY KEY,
+ type TEXT NOT NULL CONSTRAINT query_type CHECK
+ ( type IN ( 'SELECT', 'UNION', 'INTERSECT', 'EXCEPT' ) ),
+ use_all BOOLEAN NOT NULL DEFAULT FALSE,
+ use_distinct BOOLEAN NOT NULL DEFAULT FALSE,
+ from_clause INT NOT NULL , --REFERENCES sql.from_clause
+ where_clause INT , --REFERENCES sql.expression
+ --DEFERRABLE INITIALLY DEFERRED,
+ having_clause INT --REFERENCES sql.expression
+ --DEFERRABLE INITIALLY DEFERRED
+);
+
+-- (Foreign keys to be defined later after other tables are created)
+
+CREATE TABLE sql.query_sequence (
+ id SERIAL PRIMARY KEY,
+ parent_query INT NOT NULL
+ REFERENCES sql.stored_query
+ ON DELETE CASCADE
+ DEFERRABLE INITIALLY DEFERRED,
+ seq_no INT NOT NULL,
+ child_query INT NOT NULL
+ REFERENCES sql.stored_query
+ ON DELETE CASCADE
+ DEFERRABLE INITIALLY DEFERRED,
+ CONSTRAINT sql_query_seq UNIQUE( parent_query, seq_no )
+);
+
+COMMIT;
More information about the open-ils-commits
mailing list