Class: Woods::Notion::Mappers::MigrationMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/woods/notion/mappers/migration_mapper.rb

Overview

Extracts latest migration dates per table from migration ExtractedUnits.

Used to update Data Models pages with the most recent schema change date.

Examples:

mapper = MigrationMapper.new
changes = mapper.latest_changes(migration_units)
# => { "users" => "2026-02-20T10:00:00Z", "posts" => "2026-01-15T09:00:00Z" }

Instance Method Summary collapse

Instance Method Details

#latest_changes(migration_units) ⇒ Hash<String, String>

Compute the latest migration date for each affected table.

Parameters:

  • migration_units (Array<Hash>)

    Parsed migration ExtractedUnit JSONs

Returns:

  • (Hash<String, String>)

    Table name to latest extracted_at timestamp



20
21
22
23
24
25
26
27
28
# File 'lib/woods/notion/mappers/migration_mapper.rb', line 20

def latest_changes(migration_units)
  migration_units.each_with_object({}) do |unit, changes|
    extracted_at = unit['extracted_at']
    next unless extracted_at

    tables = (unit['metadata'] || {})['tables_affected'] || []
    tables.each { |table| update_latest(changes, table, extracted_at) }
  end
end