Migrate Old CohortManifest SQLite to New Schema
Source:R/migrateCohortManifest.R
migrateCohortManifest.RdOne-time migration utility that converts an existing cohortManifest.sqlite
(picard <= 0.0.3) to the new schema with category, source_type, cohort_type,
depends_on, dependency_rule, and timestamp columns.
Arguments
- dbPath
Character. Path to the existing
cohortManifest.sqlitefile. Defaults to"inputs/cohorts/cohortManifest.sqlite".- categoryMap
Named list. Maps cohort labels to categories. Example:
list("Type 2 Diabetes" = "target", "GI Bleed" = "outcome"). Cohorts not in the map will be assigned from tag keywords or "unclassified".
Details
The migration performs the following steps:
Backs up the old database to
cohortManifest_backup_{timestamp}.sqliteReads all rows from the old schema
Infers
source_typefrom file path (json/-> "circe",sql/-> "sql",derived/-> "derived")Infers
cohort_typefrom oldcohortTypecolumnAssigns
categoryfromcategoryMap, tag keywords, or defaults to "unclassified"Converts tags from pipe-delimited string to JSON named list
Reads sidecar
.jsonmetadata for dependent cohorts ->dependency_ruleanddepends_onCreates new schema with unique indexes
Inserts migrated rows
Prints migration summary