Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

PreservationEvent to Event (Technical Notes)

David Chandek-Stark edited this page Apr 30, 2015 · 1 revision

Current Schemas

  create_table "event_logs", force: true do |t|
    t.datetime "event_date_time"
    t.string   "agent_type"
    t.integer  "user_id"
    t.string   "software_agent_value"
    t.string   "action"
    t.string   "model"
    t.string   "object_identifier"
    t.string   "application_version"
    t.text     "comment"
    t.datetime "created_at"
    t.datetime "updated_at"
  end

  create_table "preservation_events", force: true do |t|
    t.datetime "event_date_time"
    t.text     "event_detail"
    t.string   "event_type"
    t.string   "event_id_type"
    t.string   "event_id_value"
    t.string   "event_outcome"
    t.text     "event_outcome_detail_note"
    t.string   "linking_object_id_type"
    t.string   "linking_object_id_value"
    t.datetime "created_at",                null: false
    t.datetime "updated_at",                null: false
  end

Schema migration - EventLog

# The rows represent events, not event logs
rename table -> "events"

# Clarifies that it is not related to an "identifier" metadata value
rename "object_identifier" -> "pid"  

# Implement single table inheritance
rename "action" -> "type"

# For PE event_detail
string "summary"

# For PE event_outcome
string "outcome"

# For PE event_outcome_detail_note
text "detail"

# Redundant -- only possibly needs to be recorded on a purge, if ever
drop "model"                         

# Implicit: "person" if user_id present, otherwise "software"
drop "agent_type"                    

# Not used
drop "software_agent_value"

rename "application_version" -> "software"

Post-migration:

  • Update null "outcome" values to "success".
  • Update "type" values to subclass names (e.g., "fixity check" -> "FixityCheck")

Data Migration - PreservationEvent to EventLog

Migrate from/to columns:

PreservationEvent         -> Event
-------------------------------------------
event_date_time           -> event_date_time
event_id_type             -> (DROPPED, use "Duke Digital Repository Event ID" on export)
event_id_value            -> (DROPPED, use Event id on export)
event_detail              -> summary         
event_type                -> type (value not copied, use appropriate subclass name)
event_outcome             -> outcome        
event_outcome_detail_note -> detail 
linking_object_id_type    -> (DROPPED -- always "object")
linking_object_id_value   -> pid            
created_at                -> created_at
updated_at                -> updated_at

Migration Process

  • Read PreservationEvent, create Event subclass instance
  • Copy values from PE to Event
  • Save Event
  • Don't delete PE, will drop table later
Clone this wiki locally