[open-ils-commits] r15946 - in trunk/Open-ILS/src/sql/Pg: . upgrade (scottmk)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Mar 24 11:41:43 EDT 2010
Author: scottmk
Date: 2010-03-24 11:41:40 -0400 (Wed, 24 Mar 2010)
New Revision: 15946
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0207.schema.query.nullable-table-alias.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/008.schema.query.sql
Log:
Clear up some muddlement in the design of query.from_relation.
The table_alias column should be nullable, but it shouldn't be required
to be null for a core table.
M Open-ILS/src/sql/Pg/002.schema.config.sql
M Open-ILS/src/sql/Pg/008.schema.query.sql
A Open-ILS/src/sql/Pg/upgrade/0207.schema.query.nullable-table-alias.sql
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-03-24 14:32:25 UTC (rev 15945)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-03-24 15:41:40 UTC (rev 15946)
@@ -59,7 +59,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0206'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0207'); -- Scott McKellar
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/008.schema.query.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/008.schema.query.sql 2010-03-24 14:32:25 UTC (rev 15945)
+++ trunk/Open-ILS/src/sql/Pg/008.schema.query.sql 2010-03-24 15:41:40 UTC (rev 15946)
@@ -190,7 +190,7 @@
class_name TEXT,
subquery INT REFERENCES query.stored_query,
function_call INT REFERENCES query.expression,
- table_alias TEXT NOT NULL,
+ table_alias TEXT,
parent_relation INT REFERENCES query.from_relation
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
@@ -203,7 +203,7 @@
DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT join_or_core CHECK (
( parent_relation IS NULL AND join_type IS NULL
- AND on_clause IS NULL and table_alias IS NULL )
+ AND on_clause IS NULL )
OR
( parent_relation IS NOT NULL AND join_type IS NOT NULL
AND on_clause IS NOT NULL )
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0207.schema.query.nullable-table-alias.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0207.schema.query.nullable-table-alias.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0207.schema.query.nullable-table-alias.sql 2010-03-24 15:41:40 UTC (rev 15946)
@@ -0,0 +1,23 @@
+BEGIN;
+
+-- Allow table_alias to be nullable, but don't require it
+-- to be null for core tables.
+
+INSERT INTO config.upgrade_log (version) VALUES ('0207'); -- Scott McKellar
+
+ALTER TABLE query.from_relation
+ ALTER COLUMN table_alias DROP NOT NULL;
+
+ALTER TABLE query.from_relation
+ DROP CONSTRAINT join_or_core;
+
+ALTER TABLE query.from_relation
+ ADD CONSTRAINT join_or_core CHECK (
+ ( parent_relation IS NULL AND join_type IS NULL
+ AND on_clause IS NULL )
+ OR
+ ( parent_relation IS NOT NULL AND join_type IS NOT NULL
+ AND on_clause IS NOT NULL )
+ );
+
+COMMIT;
More information about the open-ils-commits
mailing list