LP#845096 - coded_value_map_id_seq doesn't have a proper last_value
authorMichael Peters <mrpeters@library.in.gov>
Tue, 10 Apr 2012 20:12:13 +0000 (16:12 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 11 Jun 2012 15:59:38 +0000 (11:59 -0400)
Thanks to Kathy Lussier for the original report.  Kathy discovered
that users were unable to add new Coded Value Maps via the staff client.

With some log digging, I discovered the culprit was a rash of
primary key errors.

With help from Dan Scott, I was able to rectify this via a quick bit
of SQL which properly sets the last_value in the sequence.

Thanks, Kathy and Dan!

Signed-off-by: Michael Peters <mrpeters@library.in.gov>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0716.coded_value_map_id_seq_fix.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/version-upgrade/2.1-2.2-upgrade-db.sql

index fe2a1da..9bd3994 100644 (file)
@@ -87,7 +87,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0715', :eg_version); -- dbs/berick
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('0716', :eg_version); -- mrpeters/dyrcona
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 4478d7a..7e12de3 100644 (file)
@@ -6349,6 +6349,7 @@ INSERT INTO config.coded_value_map (id, ctype, code, value) VALUES
     (535, 'bib_level', 'm', oils_i18n_gettext('535', 'Monograph/Item', 'ccvm', 'value')),
     (536, 'bib_level', 's', oils_i18n_gettext('536', 'Serial', 'ccvm', 'value'));
 
+SELECT SETVAL('config.coded_value_map_id_seq'::TEXT, (SELECT max(id) FROM config.coded_value_map));
 
 -- Trigger Event Definitions -------------------------------------------------
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/0716.coded_value_map_id_seq_fix.sql b/Open-ILS/src/sql/Pg/upgrade/0716.coded_value_map_id_seq_fix.sql
new file mode 100644 (file)
index 0000000..f1d7b57
--- /dev/null
@@ -0,0 +1,9 @@
+-- Evergreen DB patch 0716.coded_value_map_id_seq_fix.sql
+BEGIN;
+
+-- check whether patch can be applied
+SELECT evergreen.upgrade_deps_block_check('0716', :eg_version);
+
+SELECT SETVAL('config.coded_value_map_id_seq'::TEXT, (SELECT max(id) FROM config.coded_value_map));
+
+COMMIT;
index 8329a41..27f0fe1 100644 (file)
@@ -12417,6 +12417,13 @@ INSERT INTO permission.perm_list ( id, code, description )
         )
     );
 
+
+-- Evergreen DB patch 0716.coded_value_map_id_seq_fix.sql
+
+SELECT evergreen.upgrade_deps_block_check('0716', :eg_version);
+
+SELECT SETVAL('config.coded_value_map_id_seq'::TEXT, (SELECT max(id) FROM config.coded_value_map));
+
 COMMIT;
 
 \qecho ************************************************************************