From 8f57f7ac9a62b404229ce8d2633a6436b91e6a2c Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 25 Nov 2009 18:49:34 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@15027 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/sql/Pg/002.schema.config.sql | 2 +- .../upgrade/0092.schema.action_trigger.event.user_data.sql | 7 +++++++ .../src/sql/Pg/upgrade/0093.schema.is_json.function.sql | 13 +++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/0093.schema.is_json.function.sql diff --git a/Open-ILS/src/sql/Pg/002.schema.config.sql b/Open-ILS/src/sql/Pg/002.schema.config.sql index 41918ea92c..bc919a1c72 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 ('0092'); -- miker +INSERT INTO config.upgrade_log (version) VALUES ('0093'); -- miker CREATE TABLE config.bib_source ( id SERIAL PRIMARY KEY, diff --git a/Open-ILS/src/sql/Pg/upgrade/0092.schema.action_trigger.event.user_data.sql b/Open-ILS/src/sql/Pg/upgrade/0092.schema.action_trigger.event.user_data.sql index b99f9f6748..f2af804408 100644 --- a/Open-ILS/src/sql/Pg/upgrade/0092.schema.action_trigger.event.user_data.sql +++ b/Open-ILS/src/sql/Pg/upgrade/0092.schema.action_trigger.event.user_data.sql @@ -2,6 +2,13 @@ BEGIN; 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; diff --git a/Open-ILS/src/sql/Pg/upgrade/0093.schema.is_json.function.sql b/Open-ILS/src/sql/Pg/upgrade/0093.schema.is_json.function.sql new file mode 100644 index 0000000000..e4630f830b --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/0093.schema.is_json.function.sql @@ -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; + -- 2.11.0