Change a datatype in query.record_column.
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/0104.schema.query-expr-string.sql
M Open-ILS/examples/fm_IDL.xml
git-svn-id: svn://svn.open-ils.org/ILS/trunk@15070
dcc99617-32d9-48b4-a31d-
7c20da2025e4
</permacrud>
</class>
+ <class id="xstr" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="query::expr_string" oils_persist:tablename="query.expr_string" reporter:label="String Expression">
+ <fields oils_persist:primary="id" oils_persist:sequence="expression_id_seq">
+ <field reporter:label="Expression ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Is Parenthesized" name="parenthesize" reporter:datatype="bool"/>
+ <field reporter:label="Parent Expression" name="parent_expr" reporter:datatype="link"/>
+ <field reporter:label="Sequence Number" name="seq_no" reporter:datatype="int"/>
+ <field reporter:label="Literal" name="literal" reporter:datatype="text"/>
+ </fields>
+ <links>
+ <link field="parent_expr" reltype="might_have" 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. -->
<!-- ********************************************************************************************************************* -->
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0103'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0104'); -- Scott McKellar
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
DEFERRABLE INITIALLY DEFERRED,
seq_no INT NOT NULL,
column_name TEXT NOT NULL,
- column_type 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)
);
--- /dev/null
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0104'); -- Scott McKellar
+
+-- Create updatable view
+
+CREATE OR REPLACE VIEW query.expr_string AS
+ SELECT
+ id,
+ parenthesize,
+ parent_expr,
+ seq_no,
+ literal
+ FROM
+ query.expression
+ WHERE
+ type = 'xstr';
+
+CREATE OR REPLACE RULE query_expr_string_insert_rule AS
+ ON INSERT TO query.expr_string
+ DO INSTEAD
+ INSERT INTO query.expression (
+ id,
+ type,
+ parenthesize,
+ parent_expr,
+ seq_no,
+ literal
+ ) VALUES (
+ COALESCE(NEW.id, NEXTVAL('query.expression_id_seq'::REGCLASS)),
+ 'xstr',
+ COALESCE(NEW.parenthesize, FALSE),
+ NEW.parent_expr,
+ COALESCE(NEW.seq_no, 1),
+ NEW.literal
+ );
+
+CREATE OR REPLACE RULE query_expr_string_update_rule AS
+ ON UPDATE TO query.expr_string
+ DO INSTEAD
+ UPDATE query.expression SET
+ id = NEW.id,
+ parenthesize = NEW.parenthesize,
+ parent_expr = NEW.parent_expr,
+ seq_no = NEW.seq_no,
+ literal = NEW.literal
+ WHERE
+ id = OLD.id;
+
+CREATE OR REPLACE RULE query_expr_string_delete_rule AS
+ ON DELETE TO query.expr_string
+ DO INSTEAD
+ DELETE FROM query.expression WHERE id = OLD.id;
+
+COMMIT;