From: scottmk Date: Mon, 30 Nov 2009 19:58:13 +0000 (+0000) Subject: Add two tables to the sql schema: stored_query and query_sequence. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d7d02db550b646baf6bd580faedfa0ff5e962aa1;p=evergreen%2Fpines.git 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@15045 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 2d53ec3703..950dd78798 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -5333,6 +5333,37 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index e2be7f109a..5170d61fcd 100644 --- a/Open-ILS/src/sql/Pg/002.schema.config.sql +++ b/Open-ILS/src/sql/Pg/002.schema.config.sql @@ -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 ('0097'); -- Scott McKellar +INSERT INTO config.upgrade_log (version) VALUES ('0098'); -- Scott McKellar CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0098.schema.sql-stored-query.sql b/Open-ILS/src/sql/Pg/upgrade/0098.schema.sql-stored-query.sql new file mode 100644 index 0000000000..1134f31982 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0098.schema.sql-stored-query.sql @@ -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;