fix: product deletion survives restart (one-time seed marker)#4
Merged
Conversation
A product deleted via the UI/API reappeared after a restart: the seed migration re-imported any product missing from the DB on every startup, resurrecting it from its lingering ConfigRoot/products/*.json seed file. Add a SeedState marker document recorded once the import has run; the migration returns early when the marker is present and never re-reads the seed files again. Existing/pre-marker databases (already populated) are marked seeded on first boot without re-importing, so previously-deleted products stay deleted. Empty DB + no seed files stays unseeded so a later boot with seed files can still import them once. Regression test: ProductSeedMigrationTests asserts a ghost seed file for a product absent from the DB is not re-imported once the marker exists. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
A product deleted via the Admin UI / API came back after a backend restart. Root cause: the product-seed migration re-imported any product missing from the database on every startup (
if (existing != null) continue;), so a product deleted from the DB — while itsConfigRoot/products/*.jsonseed file lingered on disk — was resurrected on the next boot. This contradicts the documented "JSON files are a one-time startup seed; DB is the source of truth" design decision.Fix
SeedStatemarker document (shelf.mt_doc_seedstate, idproducts) records that the import has run.ProductConfigMigrationService.StartAsyncreturns early when the marker is present — the seed JSON is never read again.Tests
ProductSeedMigrationTests.Migration_DoesNotReimportSeedFiles_OnceSeeded: with the marker present, a ghost seed file for a product absent from the DB is not re-imported.capabilities= 0 rows).Fixes the regression shipped in 2.1.0. CHANGELOG updated with a 2.1.1 entry.
🤖 Generated with Claude Code