Skip to content

fix: product deletion survives restart (one-time seed marker)#4

Merged
windischb merged 2 commits into
developfrom
fix/product-deletion-seed-resurrection
Jul 19, 2026
Merged

fix: product deletion survives restart (one-time seed marker)#4
windischb merged 2 commits into
developfrom
fix/product-deletion-seed-resurrection

Conversation

@windischb

Copy link
Copy Markdown
Contributor

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 its ConfigRoot/products/*.json seed 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

  • New SeedState marker document (shelf.mt_doc_seedstate, id products) records that the import has run.
  • ProductConfigMigrationService.StartAsync returns early when the marker is present — the seed JSON is never read again.
  • Upgrade path: an already-populated DB with no marker (pre-2.1.1, or products created purely via the UI/API) is marked seeded without re-importing, so previously-deleted products stay deleted.
  • Empty DB + no seed files stays unseeded, so a later boot that does have seed files can still import them once.

Tests

  • New regression test ProductSeedMigrationTests.Migration_DoesNotReimportSeedFiles_OnceSeeded: with the marker present, a ghost seed file for a product absent from the DB is not re-imported.
  • Verified end-to-end on the dev stack: delete a JSON-seeded product → restart → it stays gone (13 products, capabilities = 0 rows).

Fixes the regression shipped in 2.1.0. CHANGELOG updated with a 2.1.1 entry.

🤖 Generated with Claude Code

windischb and others added 2 commits July 19, 2026 12:24
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>
@windischb
windischb merged commit 64c2b1e into develop Jul 19, 2026
2 checks passed
@windischb
windischb deleted the fix/product-deletion-seed-resurrection branch July 19, 2026 10:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant