[๐ ] Version routing for body records without breaking old Daily Reviews
โจ GPT-5.6 Solโs Summary ใ
A record of discovering that continued changes to the body-record UI could make older journal entries incompatible with the latest structure, then tying the renderer, schema, and validator to the same version through a single schema_version.
body_review had a version, but the renderer ignored it
After building a diet and meal-tracking MVP inside the blog, I separated Today from Last 7 days in the collapsed view and stopped the expanded cards from breaking at narrow widths. I also changed the white stars in coaching verdicts to use the same rating display as the body record.
As I kept changing the screen, a larger problem became visible. The front matter already had schema_version, but _includes/body-review.html ignored it and rendered the latest structure directly. If the data structure changed later, old Daily Reviews could enter the newest renderer and break.
Route directly to the vN renderer from schema_version
I did not fill body-review.html with a growing list of version-specific case when branches. It builds the path from the number and includes that file directly.
{%- assign schema_version = review.schema_version | plus: 0 -%}
{%- capture renderer_path -%}body-review/v{{ schema_version }}.html{%- endcapture -%}
{% include {{ renderer_path }} review=review %}
v4 goes to body-review/v4.html, and v100 goes to body-review/v100.html. There is no upper limit that suddenly blocks v101. If the corresponding version file exists, the same rule connects it. If it does not, the build fails instead of silently falling back to the latest version.
Keep the renderer, schema, and validator on the same number
Versioning only the screen could still let input validation drift away. I therefore made each version a set of three files.
_includes/body-review/v4.html
_project/blog-system/body-review-schemas/v4.yml
_project/blog-system/body-review-validators/v4.rb
The checker finds every vN in the repository and fails if any of the three files is missing or if the renderer lacks its body-review--vN marker. A new version is added only when the data structure must change, while an already published post continues to be interpreted by the version it declares.
I also used v4 to clean up the visible problems that were bothering me. The collapsed summary places Today and Last 7 days on separate rows, and the expanded cards move from three columns to two and then one according to the componentโs own width. Body records and coaching verdicts use the same rating include, while UI text and accessibility labels come from data for each active language.
Simple copy or style changes can now stay inside v4. A change that breaks the data shape gets a new vN set instead. Building a new screen no longer means rewriting all the old journal entries at the same time.
Leave a comment