[open-ils-commits] r17649 - in branches/rel_2_0/Open-ILS/src/sql/Pg: . upgrade (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Sep 14 11:28:58 EDT 2010
Author: miker
Date: 2010-09-14 11:28:55 -0400 (Tue, 14 Sep 2010)
New Revision: 17649
Added:
branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0393.schema.perm-id-change-i18n-protection.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0395.schema.fix-i18n-fixer.sql
Modified:
branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
branches/rel_2_0/Open-ILS/src/sql/Pg/006.schema.permissions.sql
Log:
Backport I18N protection for permission descriptions
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-09-14 15:25:38 UTC (rev 17648)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/002.schema.config.sql 2010-09-14 15:28:55 UTC (rev 17649)
@@ -68,7 +68,7 @@
install_date TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
-INSERT INTO config.upgrade_log (version) VALUES ('0392'); -- phasefx
+INSERT INTO config.upgrade_log (version) VALUES ('0393'); -- miker
CREATE TABLE config.bib_source (
id SERIAL PRIMARY KEY,
@@ -647,6 +647,34 @@
CREATE UNIQUE INDEX i18n_identity ON config.i18n_core (fq_field,identity_value,translation);
+CREATE OR REPLACE FUNCTION oils_i18n_update_apply(old_ident TEXT, new_ident TEXT, hint TEXT) RETURNS VOID AS $_$
+BEGIN
+
+ EXECUTE $$
+ UPDATE config.i18n_core
+ SET identity_value = $$ || quote_literal(new_ident) || $$
+ WHERE fq_field LIKE '$$ || hint || $$.%'
+ AND identity_value = $$ || quote_literal(old_ident) || $$::TEXT;$$;
+
+ RETURN;
+
+END;
+$_$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION oils_i18n_id_tracking(/* hint */) RETURNS TRIGGER AS $_$
+BEGIN
+ PERFORM oils_i18n_update_apply( OLD.id::TEXT, NEW.id::TEXT, TG_ARGV[0]::TEXT );
+ RETURN NEW;
+END;
+$_$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION oils_i18n_code_tracking(/* hint */) RETURNS TRIGGER AS $_$
+BEGIN
+ PERFORM oils_i18n_update_apply( OLD.code::TEXT, NEW.code::TEXT, TG_ARGV[0]::TEXT );
+ RETURN NEW;
+END;
+$_$ LANGUAGE PLPGSQL;
+
CREATE TABLE config.billing_type (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
Modified: branches/rel_2_0/Open-ILS/src/sql/Pg/006.schema.permissions.sql
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/006.schema.permissions.sql 2010-09-14 15:25:38 UTC (rev 17648)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/006.schema.permissions.sql 2010-09-14 15:28:55 UTC (rev 17649)
@@ -27,6 +27,9 @@
description TEXT
);
CREATE INDEX perm_list_code_idx ON permission.perm_list (code);
+CREATE TRIGGER maintain_perm_i18n_tgr
+ AFTER UPDATE ON permission.perm_list
+ FOR EACH ROW EXECUTE PROCEDURE oils_i18n_id_tracking('ppl');
CREATE TABLE permission.grp_tree (
id SERIAL PRIMARY KEY,
Copied: branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0393.schema.perm-id-change-i18n-protection.sql (from rev 17634, trunk/Open-ILS/src/sql/Pg/upgrade/0393.schema.perm-id-change-i18n-protection.sql)
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0393.schema.perm-id-change-i18n-protection.sql (rev 0)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0393.schema.perm-id-change-i18n-protection.sql 2010-09-14 15:28:55 UTC (rev 17649)
@@ -0,0 +1,38 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0393'); -- miker
+
+CREATE OR REPLACE FUNCTION oils_i18n_update_apply(old_ident TEXT, new_ident TEXT, hint TEXT) RETURNS VOID AS $_$
+BEGIN
+
+ EXECUTE $$
+ UPDATE config.i18n_core
+ SET identity_value = $$ || new_ident || $$
+ WHERE fq_field LIKE '$$ || hint || $$.%'
+ AND identity_value = $$ || old_ident || $$;$$;
+
+ RETURN;
+
+END;
+$_$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION oils_i18n_id_tracking(/* hint */) RETURNS TRIGGER AS $_$
+BEGIN
+ PERFORM oils_i18n_update_apply( OLD.id::TEXT, NEW.id::TEXT, TG_ARGV[0]::TEXT );
+ RETURN NEW;
+END;
+$_$ LANGUAGE PLPGSQL;
+
+CREATE OR REPLACE FUNCTION oils_i18n_code_tracking(/* hint */) RETURNS TRIGGER AS $_$
+BEGIN
+ PERFORM oils_i18n_update_apply( OLD.code::TEXT, NEW.code::TEXT, TG_ARGV[0]::TEXT );
+ RETURN NEW;
+END;
+$_$ LANGUAGE PLPGSQL;
+
+
+CREATE TRIGGER maintain_perm_i18n_tgr
+ AFTER UPDATE ON permission.perm_list
+ FOR EACH ROW EXECUTE PROCEDURE oils_i18n_id_tracking('ppl');
+
+COMMIT;
Copied: branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0395.schema.fix-i18n-fixer.sql (from rev 17645, trunk/Open-ILS/src/sql/Pg/upgrade/0395.schema.fix-i18n-fixer.sql)
===================================================================
--- branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0395.schema.fix-i18n-fixer.sql (rev 0)
+++ branches/rel_2_0/Open-ILS/src/sql/Pg/upgrade/0395.schema.fix-i18n-fixer.sql 2010-09-14 15:28:55 UTC (rev 17649)
@@ -0,0 +1,19 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0395'); -- Scott McKellar
+
+CREATE OR REPLACE FUNCTION oils_i18n_update_apply(old_ident TEXT, new_ident TEXT, hint TEXT) RETURNS VOID AS $_$
+BEGIN
+
+ EXECUTE $$
+ UPDATE config.i18n_core
+ SET identity_value = $$ || quote_literal( new_ident ) || $$
+ WHERE fq_field LIKE '$$ || hint || $$.%'
+ AND identity_value = $$ || quote_literal( old_ident ) || $$;$$;
+
+ RETURN;
+
+END;
+$_$ LANGUAGE PLPGSQL;
+
+COMMIT;
More information about the open-ils-commits
mailing list