Skip to content

Commit 2dcf763

Browse files
fix for possible script failure
1 parent 3a230ea commit 2dcf763

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

sormas-backend/src/main/resources/sql/sormas_schema.sql

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15470,8 +15470,15 @@ INSERT INTO schema_version (version_number, comment) VALUES (614, '#13887 - Expo
1547015470
-- 23-03-2026 new fields related to Malaria and Dengue samples and pathogenform.
1547115471
ALTER TABLE pathogentest ADD COLUMN IF NOT EXISTS serotypetext varchar(255);
1547215472
UPDATE pathogentest SET serotypetext = serotype, serotype = 'OTHER' WHERE serotype IS NOT null and serotypetext is null;
15473-
ALTER TABLE pathogentest rename column genotyperesult to genotype;
15474-
ALTER TABLE pathogentest rename column genotyperesulttext to genotypetext;
15473+
DO $$
15474+
BEGIN
15475+
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'pathogentest' AND column_name = 'genotyperesult') THEN
15476+
ALTER TABLE pathogentest RENAME COLUMN genotyperesult TO genotype;
15477+
END IF;
15478+
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'pathogentest' AND column_name = 'genotyperesulttext') THEN
15479+
ALTER TABLE pathogentest RENAME COLUMN genotyperesulttext TO genotypetext;
15480+
END IF;
15481+
END $$;
1547515482
ALTER TABLE pathogentest ADD COLUMN IF NOT EXISTS antibodyTitre varchar(255);
1547615483
ALTER TABLE pathogentest ADD COLUMN IF NOT EXISTS performedByReferenceLaboratory boolean;
1547715484
ALTER TABLE pathogentest ADD COLUMN IF NOT EXISTS retestRequested boolean default false;
@@ -15483,8 +15490,16 @@ ALTER TABLE healthconditions ADD COLUMN IF NOT EXISTS malariainfectedyear intege
1548315490

1548415491
ALTER TABLE pathogentest_history ADD COLUMN IF NOT EXISTS serotypetext varchar(255);
1548515492
UPDATE pathogentest_history SET serotypetext = serotype, serotype = 'OTHER' WHERE serotype IS NOT null and serotypetext is null;
15486-
ALTER TABLE pathogentest_history rename column genotyperesult to genotype;
15487-
ALTER TABLE pathogentest_history rename column genotyperesulttext to genotypetext;
15493+
DO $$
15494+
BEGIN
15495+
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'pathogentest_history' AND column_name = 'genotyperesult') THEN
15496+
ALTER TABLE pathogentest_history RENAME COLUMN genotyperesult TO genotype;
15497+
END IF;
15498+
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'pathogentest_history' AND column_name = 'genotyperesulttext') THEN
15499+
ALTER TABLE pathogentest_history RENAME COLUMN genotyperesulttext TO genotypetext;
15500+
END IF;
15501+
END $$;
15502+
1548815503
ALTER TABLE pathogentest_history ADD COLUMN IF NOT EXISTS antibodyTitre varchar(255);
1548915504
ALTER TABLE pathogentest_history ADD COLUMN IF NOT EXISTS performedByReferenceLaboratory boolean;
1549015505
ALTER TABLE pathogentest_history ADD COLUMN IF NOT EXISTS retestRequested boolean default false;

0 commit comments

Comments
 (0)