From a6867a9b26a39f89d0246155c563e8c260443c44 Mon Sep 17 00:00:00 2001 From: Ben Shum Date: Thu, 14 Sep 2017 23:16:32 -0400 Subject: [PATCH] LP#1666512 - Only insert if not already existing This repatch was requested by Galen Charlton to make it easier for upgrades to avoid adding the entries or failing if the entries already existed. Also drops the unnecessary i18n tagging for the billing type names since it does not work with applying upgrade scripts (only for sourcing db.seed data for translation to PO file) Signed-off-by: Ben Shum --- .../XXXX.data.add_possibly_missing_billing_types.sql | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.add_possibly_missing_billing_types.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.add_possibly_missing_billing_types.sql index a9d3d5c732..256c55804f 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.add_possibly_missing_billing_types.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.add_possibly_missing_billing_types.sql @@ -7,11 +7,16 @@ SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version); -- add them here. It's okay if they fail, so this should probably be -- run outside a transaction if added to the version-upgrade scripts. -INSERT INTO config.billing_type (id, name, owner) VALUES - ( 7, oils_i18n_gettext(7, 'Damaged Item', 'cbt', 'name'), 1); -INSERT INTO config.billing_type (id, name, owner) VALUES - ( 8, oils_i18n_gettext(8, 'Damaged Item Processing Fee', 'cbt', 'name'), 1); -INSERT INTO config.billing_type (id, name, owner) VALUES - ( 9, oils_i18n_gettext(9, 'Notification Fee', 'cbt', 'name'), 1); +INSERT INTO config.billing_type (id, name, owner) + SELECT 7, 'Damaged Item', 1 + WHERE NOT EXISTS (SELECT 1 FROM config.billing_type WHERE name = 'Damaged Item'); + +INSERT INTO config.billing_type (id, name, owner) + SELECT 8, 'Damaged Item Processing Fee', 1 + WHERE NOT EXISTS (SELECT 1 FROM config.billing_type WHERE name = 'Damaged Item Processing Fee'); + +INSERT INTO config.billing_type (id, name, owner) + SELECT 9, 'Notification Fee', 1 + WHERE NOT EXISTS (SELECT 1 FROM config.billing_type WHERE name = 'Notification Fee'); COMMIT; -- 2.11.0