Skip to content

Commit cf519b6

Browse files
authored
Update sql schema with TestReport renamed columns (#13901)
* Update sql schema with TestReport renamed columns * Fixed remarks in sql schema
1 parent c56cc1f commit cf519b6

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15507,4 +15507,35 @@ ALTER TABLE healthconditions_history ADD COLUMN IF NOT EXISTS malaria varchar(25
1550715507
ALTER TABLE healthconditions_history ADD COLUMN IF NOT EXISTS malariainfectedyear integer ;
1550815508

1550915509
INSERT INTO schema_version (version_number, comment) VALUES (615, '#13801, #13814 - Malaria and Dengue sampel changes');
15510-
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***
15510+
15511+
-- 07-04-2026 Test report new fields related to Malaria and Dengue samples and pathogenform.
15512+
ALTER TABLE testreport ADD COLUMN IF NOT EXISTS serotypetext varchar(255);
15513+
UPDATE testreport SET serotypetext = serotype, serotype = 'OTHER' WHERE serotype IS NOT null and serotypetext is null;
15514+
DO $$
15515+
BEGIN
15516+
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'testreport' AND column_name = 'genotyperesult')
15517+
AND NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'testreport' AND column_name = 'genotype') THEN
15518+
ALTER TABLE testreport RENAME COLUMN genotyperesult TO genotype;
15519+
END IF;
15520+
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'testreport' AND column_name = 'genotyperesulttext')
15521+
AND NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'testreport' AND column_name = 'genotypetext') THEN
15522+
ALTER TABLE testreport RENAME COLUMN genotyperesulttext TO genotypetext;
15523+
END IF;
15524+
END $$;
15525+
15526+
ALTER TABLE testreport_history ADD COLUMN IF NOT EXISTS serotypetext varchar(255);
15527+
UPDATE testreport_history SET serotypetext = serotype, serotype = 'OTHER' WHERE serotype IS NOT null and serotypetext is null;
15528+
DO $$
15529+
BEGIN
15530+
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'testreport_history' AND column_name = 'genotyperesult')
15531+
AND NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'testreport_history' AND column_name = 'genotype') THEN
15532+
ALTER TABLE testreport_history RENAME COLUMN genotyperesult TO genotype;
15533+
END IF;
15534+
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'testreport_history' AND column_name = 'genotyperesulttext')
15535+
AND NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = 'testreport_history' AND column_name = 'genotypetext') THEN
15536+
ALTER TABLE testreport_history RENAME COLUMN genotyperesulttext TO genotypetext;
15537+
END IF;
15538+
END $$;
15539+
15540+
INSERT INTO schema_version (version_number, comment) VALUES (616, '#13801, #13814 - Malaria and Dengue TestReport columns renames');
15541+
-- *** Insert new sql commands BEFORE this line. Remember to always consider _history tables. ***

0 commit comments

Comments
 (0)