Module: Glossarist::SchemaMigration::V2ToV3
- Defined in:
- lib/glossarist/schema_migration/v2_to_v3.rb
Class Method Summary collapse
- .concept_version(concept) ⇒ Object
- .migrate_concept(concept, target_version: Glossarist::SCHEMA_VERSION) ⇒ Object
- .step_v2_to_v3(concept) ⇒ Object
-
.step_v2_to_v3_hyperedge_note ⇒ Object
Hyperedges: V2 has no hyperedge concept.
Class Method Details
.concept_version(concept) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/glossarist/schema_migration/v2_to_v3.rb', line 33 def self.concept_version(concept) version = concept.schema_version return version.to_s if version && !version.to_s.empty? ManagedConcept.detect_schema_version(concept) end |
.migrate_concept(concept, target_version: Glossarist::SCHEMA_VERSION) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/glossarist/schema_migration/v2_to_v3.rb', line 6 def self.migrate_concept(concept, target_version: Glossarist::SCHEMA_VERSION) current = concept_version(concept) target = target_version.to_s return concept if current == target max_steps = 5 max_steps.times do break if current == target case current when "2" then current = step_v2_to_v3(concept) else raise Errors::Base, "No concept migration step from version #{current}" end end unless current == target raise Errors::Base, "Migration chain too long or unresolvable" end concept.schema_version = target concept end |
.step_v2_to_v3(concept) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/glossarist/schema_migration/v2_to_v3.rb', line 40 def self.step_v2_to_v3(concept) # V2 placed `related` inside ManagedConceptData; V3 places it # on ManagedConcept itself. Move any data-level related entries # up to the concept level. V3::ManagedConceptData no longer # serializes `related`, so we don't need to clear the moved-from # slot — the V3 output naturally omits it. = concept.data&. return step_v2_to_v3_hyperedge_note if .nil? || .empty? concept. ||= [] concept. = (concept. + ).uniq "3" end |
.step_v2_to_v3_hyperedge_note ⇒ Object
Hyperedges: V2 has no hyperedge concept. V2's binary
broader_partitive / narrower_partitive edges migrate as
related entries (see step_v2_to_v3). Hyperedges are a V3-only
construct and require no migration logic — concepts upgraded
from V2 to V3 simply have no hyperedges.
59 60 61 |
# File 'lib/glossarist/schema_migration/v2_to_v3.rb', line 59 def self.step_v2_to_v3_hyperedge_note "3" end |