Migrate Old ConceptSetManifest SQLite to New Schema
Source:R/migrateConceptSetManifest.R
migrateConceptSetManifest.RdOne-time migration utility that converts an existing conceptSetManifest.sqlite
(picard <= 0.0.3.1) to the new schema with category, status, created_at, updated_at, and deleted_at columns,
and converts tags from pipe-delimited string format to JSON.
Usage
migrateConceptSetManifest(
dbPath = "inputs/conceptSets/conceptSetManifest.sqlite",
categoryMap = NULL
)Arguments
- dbPath
Character. Path to the existing
conceptSetManifest.sqlitefile. Defaults to"inputs/conceptSets/conceptSetManifest.sqlite".- categoryMap
Named list. Maps concept set labels to categories. Example:
list("BMI Ratio" = "measurement", "Diabetes" = "condition_occurrence"). Concept sets not in the map will be assigned from tag keywords or "init".
Details
The migration performs the following steps:
Backs up the old database to
conceptSetManifest_backup_{timestamp}.sqliteReads all rows from the old schema
Assigns
categoryfrom the tag keywords (e.g., "domain: condition_occurrence" -> "condition_occurrence") or defaults to "init" if not foundConverts tags from pipe-delimited string (e.g., "name: value | name: value") to JSON named list
Adds missing columns (category, status, created_at, updated_at, deleted_at) if they don't exist
Creates new schema with proper structure
Inserts migrated rows with
created_atandupdated_atset to oldtimestampvaluePrints migration summary
New schema columns:
id: Auto-incrementing primary keylabel: Concept set display namecategory: OMOP domain or custom categorytags: JSON object of key-value metadatafile_path: Absolute or relative path to JSON definition filehash: File hash for change detectionstatus: 'active' or 'inactive' (soft delete flag)created_at: Creation timestampupdated_at: Last update timestampdeleted_at: Soft delete timestamp (NULL if active)