Mehdi Akiki
Published on

Migrating an Ontology Without Rewriting Reality in Place

Authors
  • Mehdi Akiki avatar
    Name
    Mehdi Akiki
    Twitter

Reference

Renaming an ontology term is easy in a text editor. Migrating the production meaning of that term is not.

A class may split into two. A property may change domain. An identifier may be replaced. Old assertions, queries, indexes, cached inferences, and clients continue to exist.

I migrate the interpretation in versions. I do not rewrite all old evidence as if it had always used the new vocabulary.

A rename and a meaning change are different

Suppose V1 has:

ex:Customer

V2 uses:

ex:AccountHolder

If the sets are truly equivalent, an explicit equivalence or deterministic mapping may be valid. If Customer included prospects but AccountHolder requires an active account, this is a split and reclassification.

I classify ontology changes:

label change: same IRI and meaning, new human text
rename: new IRI intended as equivalent
split: old concept maps to several new concepts using evidence
merge: several concepts become one broader concept
narrow/widen: membership meaning changes
property change: domain, range, cardinality, or semantics changes
retirement: term remains understandable but no longer produced

The migration plan depends on the class, not only the diff.

Version the ontology artifact

OWL 2 defines ontology IRIs, version IRIs, and imports in its structural specification.

I give each released ontology and shapes bundle an immutable version identity:

ontology identity: https://example.test/ontology/customer
version identity:  https://example.test/ontology/customer/2026-11-28
content hash:       sha256:...

The product deployment records exactly which version it loads. “Latest” may be convenient for browsing and unsafe for reproducible decisions.

Preserve observations; rebuild the canonical projection

My data layers are:

source assertions: what a provider or user actually stated
mapping evidence: how source terms relate to canonical terms
canonical projection: current product interpretation
derived indexes: search, analytics, and caches

When the ontology changes, I usually rebuild or migrate the canonical and derived layers. Source assertions keep their original vocabulary and provenance.

This preserves the ability to reinterpret them under a corrected mapping later.

Mapping needs a status and evidence

A migration record can be:

{
  "source_term": "v1:Customer",
  "target_terms": ["v2:AccountHolder"],
  "relation": "conditional",
  "rule": "has-active-account@3",
  "status": "approved",
  "mapping_version": "customer-v1-to-v2@4"
}

For a split, one old term does not map without record-level evidence. I produce:

mapped with high-confidence rule
requires review
cannot map from retained evidence
invalid under new model

Unknown cases stay unknown. A migration should not manufacture precision.

Run old and new reads together

Before cutover, I build a V2 projection beside V1:

source change -> V1 projection
              -> V2 projection

Readers remain explicitly versioned. I compare:

entity counts by class
required relationship coverage
query result differences
authorization decisions
search recall slices
unmapped and multiply-mapped records
SHACL violation classes
processing cost and latency

Parity is not always equality because the model is changing. Every expected difference has a reason; unexpected differences become migration work.

Shapes migrate with meaning

The V2 vocabulary may require different product constraints. I version its SHACL shapes and validate the V2 candidate graph before activation.

Validating a Knowledge Graph at Its Product Boundary explains why ontology inference and product conformance are separate.

I do not validate V2 data with whatever shapes URL currently resolves. Ontology, shapes, mapping, and code versions form one release manifest.

Query compatibility needs a named bridge

Old queries may mention retired terms. During migration I choose:

rewrite old query to V2 with documented limits
serve old reader from the V1 projection
expose a compatibility view
reject unsupported semantics explicitly

A rewrite is safe only when meaning is preserved. Translating Customer to AccountHolder after a narrowing could silently remove prospects from an old report.

Compatibility responses include the model version used so caches and audits remain truthful.

Backfill needs checkpoints and idempotency

I partition by stable entity identity and write a versioned migration result:

entity ID
source version
mapping version
target ontology version
result hash
status and reason

Retries upsert the same result. The checkpoint advances only after the projection and migration record commit together.

Live updates run through the same mapping version, so a long backfill does not overwrite newer canonical state.

Cut over by generation

Indexes and materialized graphs can contain mixed semantics if updated in place.

I build V2 as a generation:

V1 active
V2 build and validate
freeze release manifest
switch reader alias to V2
observe
retain V1 briefly for rollback
retire by policy

Rollback changes the active projection. It does not require reversing millions of destructive term rewrites.

Deletion and retention still apply

Keeping source assertions and old projections is useful, but not permission to retain personal data forever. The migration manifest states:

which evidence is required for audit or rollback
which old derived projections can be deleted
how subject deletion reaches both versions
when compatibility readers end

Provenance references must not become a hidden indefinite copy.

Give the migration one owner and an exit

A dual-model period creates permanent complexity if nobody owns its end. My release plan names:

owner of ontology and mapping decisions
owners of each reader and derived index
threshold for unresolved records
date when V1 writes stop
date when V1 reads stop
rollback window
evidence required before old projections are removed

Compatibility metrics are reviewed by these owners, not left on an unused dashboard. If an old consumer cannot migrate, I record that as a product decision with cost and risk. “Temporary” translation code without an exit date becomes another ontology.

My migration test

I include:

  • pure rename;
  • split with enough evidence;
  • split without enough evidence;
  • merge with conflicting properties;
  • retired term in an old query;
  • late source update during backfill;
  • crash before checkpoint;
  • V1/V2 shape disagreement;
  • index-generation cutover and rollback;
  • deletion while both projections exist.

I verify semantic outcomes, not only triple counts.

An ontology is a model of meaning, and production data is evidence collected under versions of that model. Keeping source assertions immutable while projections migrate lets the model improve without pretending the past used today's vocabulary.