Open lesson

Mission: add the clue without erasing S100

Command palette

This mission workspace keeps code and notes in this browser tab. Export them before closing it. Running code is practice, not an automatic grade for the mission.

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

  1. List column IDs and names before and after the change.
  2. Show S100 and S101 when read with the new schema.
  3. Explain why None for S100 service_identity is not proof that no action occurred.
  4. 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)

Code

Use Tab to leave the editor. Ctrl+Enter runs the source. The lines beginning with # are task reminders. Python ignores them. Write your code beneath them.

Python console

Loading laboratory…

Explore Python or SQL here; this is not an operating-system shell.

This is a disposable browser experiment. The code run here is not recorded as a completed mission.

Each command starts a fresh disposable worker: it runs a captured copy of your current source, then your command with the lesson fixtures. Changes are discarded afterward. Commands never save source or award XP. Ctrl+Enter executes the command.

Virtual workspace files

Source and declarative assets are readable here without JavaScript. Python input files are created at runtime; SQL setup initializes the disposable database.

source.py

Current editor source. Inspection shows your current edits.

# 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_identity` is not proof that no action occurred.
# Plan two reader checks and one snapshot-retention measure.

exemple.py

Declarative lesson asset; this is not a file created in the Python filesystem.

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)