Fix a function that moves translations in config.i18n_core,
authorscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 14 Sep 2010 13:27:09 +0000 (13:27 +0000)
committerscottmk <scottmk@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 14 Sep 2010 13:27:09 +0000 (13:27 +0000)
so that it will handle both text-based keys and numeric keys.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@17645 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/upgrade/0395.schema.fix-i18n-fixer.sql [new file with mode: 0644]

diff --git a/Open-ILS/src/sql/Pg/upgrade/0395.schema.fix-i18n-fixer.sql b/Open-ILS/src/sql/Pg/upgrade/0395.schema.fix-i18n-fixer.sql
new file mode 100644 (file)
index 0000000..d91fb1a
--- /dev/null
@@ -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;