Fix detection of "new migrations" in omarchy-update
#219
+7
−9
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.
Previously,
omarchy-update
used the timestamp of the most recent git commit to determine which migrations are "new" and should be executed.Unfortunately, that strategy can (and did: #187) fail in certain scenarios. If a migration was generated at time T1 but not merged until time T3, and meanwhile omarchy's
master
branch was updated to a new release with commit timestamp T2 (where T1 < T2 < T3), then anyone who runsomarchy-update
between T2 and T3 would end up withlast_updated_at
equal to T2; thus, on their nextomarchy-update
it would fail to detect the migration with timestamp T1 as a "new" migration that should be executed.This PR changes the strategy for detecting "new" migrations to avoid that problem. Rather than recording the most recent commit's timestamp, we record its SHA. Then, after pulling the new changes, we can leverage
to return precisely the list of migration files that were introduced by our
git pull
. It doesn't matter if any of those migrations have a timestamp that was earlier than the timestamp of the commit we started on - we will always execute every migration that didn't exist before ourgit pull
!