From 86c7ce7c56e5b1d6497364b112a1a4a66b78b44c Mon Sep 17 00:00:00 2001 From: Peter Hoffmann <954078+p-hoffmann@users.noreply.github.com> Date: Sun, 1 Nov 2026 06:29:37 +0800 Subject: [PATCH] Create cohort_characterization_version on installs from the 3.0 baseline The B2.99.0006 baseline creates the version tables for cohorts, concept sets, incidence rates, pathways and reusables but not for characterizations, so on a fresh install every characterization update fails with SQLGrammarException while saving the previous version. Create the table if it is missing; databases upgraded from 2.x already have it. --- ...1000000__cohort_characterization_version.sql | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/resources/db/migration/postgresql/V3.0.1.20261101000000__cohort_characterization_version.sql diff --git a/src/main/resources/db/migration/postgresql/V3.0.1.20261101000000__cohort_characterization_version.sql b/src/main/resources/db/migration/postgresql/V3.0.1.20261101000000__cohort_characterization_version.sql new file mode 100644 index 0000000000..1e3fab0623 --- /dev/null +++ b/src/main/resources/db/migration/postgresql/V3.0.1.20261101000000__cohort_characterization_version.sql @@ -0,0 +1,17 @@ +-- The B2.99.0006 baseline omits cohort_characterization_version, so on a fresh install every +-- characterization update fails while saving the previous version. Databases upgraded from 2.x +-- already have it from V2.9.0.20210513111520, hence IF NOT EXISTS. +CREATE TABLE IF NOT EXISTS ${ohdsiSchema}.cohort_characterization_version ( + asset_id bigint NOT NULL, + comment character varying, + version integer DEFAULT 1 NOT NULL, + asset_json character varying NOT NULL, + archived boolean DEFAULT false NOT NULL, + created_by_id integer, + created_date timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT pk_cc_version_id PRIMARY KEY (asset_id, version), + CONSTRAINT fk_cc_version_sec_user_creator FOREIGN KEY (created_by_id) REFERENCES ${ohdsiSchema}.sec_user (id), + CONSTRAINT fk_cc_version_asset_id FOREIGN KEY (asset_id) REFERENCES ${ohdsiSchema}.cohort_characterization (id) ON DELETE CASCADE +); + +CREATE INDEX IF NOT EXISTS cc_version_asset_idx ON ${ohdsiSchema}.cohort_characterization_version USING btree (asset_id);