[open-ils-commits] r15027 - in trunk/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed Nov 25 13:49:38 EST 2009
Author: miker
Date: 2009-11-25 13:49:34 -0500 (Wed, 25 Nov 2009)
New Revision: 15027
Added:
trunk/Open-ILS/src/sql/Pg/upgrade/0093.schema.is_json.function.sql
Modified:
trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
trunk/Open-ILS/src/sql/Pg/upgrade/0092.schema.action_trigger.event.user_data.sql
Log:
add is_json() in the 0092 upgrade script, to avoid warnings ... and add it again in 0093 to fix things for folks that already updated with 0092
Modified: trunk/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-11-25 18:07:13 UTC (rev 15026)
+++ trunk/Open-ILS/src/sql/Pg/002.schema.config.sql 2009-11-25 18:49:34 UTC (rev 15027)
@@ -51,7 +51,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0092'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0093'); -- miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
Modified: trunk/Open-ILS/src/sql/Pg/upgrade/0092.schema.action_trigger.event.user_data.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0092.schema.action_trigger.event.user_data.sql 2009-11-25 18:07:13 UTC (rev 15026)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0092.schema.action_trigger.event.user_data.sql 2009-11-25 18:49:34 UTC (rev 15027)
@@ -2,6 +2,13 @@
INSERT INTO config.upgrade_log (version) VALUES ('0092'); -- miker
+CREATE OR REPLACE FUNCTION is_json (TEXT) RETURNS BOOL AS $func$
+ use JSON::XS;
+ my $json = shift();
+ eval { decode_json( $json ) };
+ return $@ ? 0 : 1;
+$func$ LANGUAGE PLPERLU;
+
ALTER TABLE action_trigger.event ADD COLUMN user_data TEXT CHECK (user_data IS NULL OR is_json( user_data ));
COMMIT;
Added: trunk/Open-ILS/src/sql/Pg/upgrade/0093.schema.is_json.function.sql
===================================================================
--- trunk/Open-ILS/src/sql/Pg/upgrade/0093.schema.is_json.function.sql (rev 0)
+++ trunk/Open-ILS/src/sql/Pg/upgrade/0093.schema.is_json.function.sql 2009-11-25 18:49:34 UTC (rev 15027)
@@ -0,0 +1,13 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0093'); -- miker
+
+CREATE OR REPLACE FUNCTION is_json (TEXT) RETURNS BOOL AS $func$
+ use JSON::XS;
+ my $json = shift();
+ eval { decode_json( $json ) };
+ return $@ ? 0 : 1;
+$func$ LANGUAGE PLPERLU;
+
+COMMIT;
+
More information about the open-ils-commits
mailing list