feat(seed): derive created_at/updated_at from git history - #65
Merged
Merged
Conversation
With ids fixed, a second dump of unchanged data still rewrote every page in 10 of 12 collections. The only difference was the two timestamps: the database is rebuilt for each dump, so they recorded when the dump ran, not when the record changed. brands and gpus were the only stable collections because their schemas do not expose them. One `git log` pass over data/ maps each record to its first and last commit time. Outside a git checkout the map is empty and the model defaults stand. Refs #1
Brand and DiscreteGPU have no created_at/updated_at, so assigning them raised ValueError on every brand insert. Refs #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second half of making the dump deterministic (first half: #63, stable ids).
Symptom. After #63 a re-dump of unchanged data still touched cpus, socs, smartphones, tablets, watches, pdas, laptops, monitors, software and websites — but not brands or gpus. Diffing a page showed the whole difference:
seedrebuilds the database per dump, so_utcnow()stamped "when the dump ran". brands/gpus were stable only because their read schemas omit both fields.Change.
_git_timestamps()runs onegit log --reverse --relative --name-only --diff-filter=AMoverdata/and maps each record path to (first commit, last commit)._row()applies it at insert. No git checkout → empty map → model defaults, as before.Checks.
tests/unit/test_git_timestamps.py(3 tests) — first/last tracking, repeat-run agreement, non-repo fallback.ruffandmypyclean; full suite has the same 28 pre-existing local failures.The first test caught a real bug before CI did:
git logreported repo-relative paths while records carry data-relative ones, so nothing matched until--relative.Refs #1