Brief
Evolve a table schema while preserving honest reading of old rows and compatibility with existing readers.
Imani asks for a column describing the technical key. Voss suggests rebuilding the whole table and discarding the old version, which would erase the comparison that defends you. Mara asks you to design a readable evolution before publication. The fictional meeting is near; the exercise has no timer.
Your mission
- List column IDs and names before and after the change.
- Show S100 and S101 when read with the new schema.
- Explain why None for S100
service_identityis not proof that no action occurred. - Plan two reader checks and one snapshot-retention measure.
How to check your work
- Field 2 stays stable through rename; field 3 is new.
- S100 keeps false and missing service identity; S101 has true and SUPPLIER-SVC.
- Historical absence interpreted as unknown.
- Old and new reports tested; S100 retained.
Course example
fields_v1={1:"vehicle_id",2:"authorized_by_recruit"}
fields_v2={1:"vehicle_id",2:"recruit_approved",3:"service_identity"}
old_row={1:"SHELL-02",2:False}
new_row={1:"SHELL-02",2:True,3:"SUPPLIER-SVC"}
def read(row,fields):
return {name:row.get(field_id) for field_id,name in fields.items()}
print("field_2_old",fields_v1[2],read(old_row,fields_v1)[fields_v1[2]])
print("field_2_new",fields_v2[2],read(old_row,fields_v2)[fields_v2[2]])
print("old_service",read(old_row,fields_v2)["service_identity"])
print("new_service",read(new_row,fields_v2)["service_identity"])
print("same_field_id",2 in fields_v1 and 2 in fields_v2)