Skip to content

V184: remove the dead shop_currency setting - #785

Merged
ddon merged 1 commit into
BeamLabEU:mainfrom
timujinne:feature/currency-e0-core
Sep 6, 2026
Merged

V184: remove the dead shop_currency setting#785
ddon merged 1 commit into
BeamLabEU:mainfrom
timujinne:feature/currency-e0-core

Conversation

@timujinne

@timujinnetimujinne commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

V184: remove the dead shop_currency setting

One new chain version. V135 seeds a shop_currency setting (INSERT … ON CONFLICT ("key") DO NOTHING, value USD, module shop). Nothing reads it: a full grep over phoenix_kit, phoenix_kit_billing, phoenix_kit_ecommerce and a host application finds only the V135 seed and the ExpectedSchema manifest. The default currency is the is_default row of phoenix_kit_currencies and nothing else; a second "shop currency" that does nothing is a trap for the next reader (a host had two disagreeing "defaults" side by side for months without noticing).

Why a new version and not an edit of V135

  • Editing a shipped vNNN.ex changes chain_hash/0 and fails release_check for every host.
  • It would also change nothing: the seed is ON CONFLICT DO NOTHING, so every already-migrated install keeps its row. Only a DELETE in a new version reaches them.

What V184 does

  • up: DELETE FROM phoenix_kit_settings WHERE "key" = 'shop_currency', marker 184.
  • down: re-inserts the row with the V135 seed statement verbatim (ON CONFLICT DO NOTHING, so a row a host re-created by hand is never overwritten), marker 183.
  • postgres.ex@current_version 184, moduledoc entry; expected_schema.ex regenerated with dev_docs/squash/generate_baseline.exs (not hand-edited).
  • Test test/phoenix_kit/migrations/v184_test.exs: up removes the row and stamps 184; down restores USD and stamps 183; down leaves a hand-created EUR row untouched.

Companion PRs in the same work (per-domain currency, stage Э0): BeamLabEU/phoenix_kit_billing#30, BeamLabEU/phoenix_kit_ecommerce#31.

Manifest and tests

  • expected_schema.ex is restamped with dev_docs/squash/restamp_chain_hash.exs --restamp — the documented path for a version that adds, drops or reshapes nothing (precedent: V182, commit 975f88f). A full regeneration was attempted first and the generator aborts on this environment at the mode-shape diff for sync_shop_category_slugs() / sync_shop_product_slugs() (identical definitions, different body_md5 between the stepwise and single-shot schemas); it aborts identically on unmodified main. Those two trigger functions are deliberately not declared in the manifest since V171 (comment near line 27778), but the generator's guard runs before that exclusion applies. Left as a tooling note, not fixed here.
  • Full suite: 43 doctests, 4497 tests, 0 failures after the restamp (before it, the only two failures were the chain-hash checks in phoenix_kit_release_check_test.exs). test/phoenix_kit/migrations/: 433 tests + 16 doctests, 0 failures, v184_test.exs included. check_migration_sync/0: V135..V184 contiguous, every module loadable.
  • Environment note: bare mix test in this checkout did not compile test/support (7 files) on its own; MIX_ENV=test mix compile --force followed by mix test --no-compile was used.

Host verification

Applied on a live host through phoenix_kit_update_v182_to_v184 (V183 + V184): shop_currency row gone, marker 184, storefront 200 on both domains, no errors in the log after restart.

Not in this PR

Version bump and CHANGELOG (maintainer). The next stage adds V185 (currency freeze columns on carts/orders).

Nothing reads it — confirmed by a full grep over phoenix_kit,
phoenix_kit_billing, phoenix_kit_ecommerce and a host application; the only
occurrences were the V135 seed and this package's own ExpectedSchema manifest
comment. A shop's actual default currency is the is_default=true row of
phoenix_kit_currencies, resolved through PhoenixKitBilling.get_default_currency/0
— a second, unread "shop currency" setting is a trap for the next reader.
V135 itself is not edited: its seed is ON CONFLICT DO NOTHING, so every
already-migrated host already has the row and editing V135's text would change
nothing for them while breaking chain_hash for everyone. down/1 restores the
row with V135's exact seed statement, so a rollback never overwrites a value
an operator re-created by hand after the deletion.
This is a pure data migration — no table, column, index or constraint is
touched — so expected_schema.ex is restamped over the 50 shipped files
(dev_docs/squash/restamp_chain_hash.exs --restamp) rather than regenerated,
the same mechanism used for V182. A full regenerate was attempted first and
aborts in this environment on a pre-existing mode-shape mismatch between the
stepwise and single-shot dumps of sync_shop_category_slugs()/
sync_shop_product_slugs() (identical definition text, different body_md5);
it aborts identically on unmodified main, and those two functions are already
deliberately excluded from this manifest since V171.

@timujinnetimujinne left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review (read-only reviewer, separate from the author), range 5de7e6c6..7ad4ce56. Verdict: PASS, no findings against the V184 work.

Verified directly

  • down/1 reproduces the V135 seed byte for byte (INSERT INTO … ("key","module","value","value_json") VALUES ('shop_currency','shop','USD',NULL) ON CONFLICT ("key") DO NOTHING); date_added/date_updated/uuid carry DB defaults, so the omitted columns are correct in both the seed and the restore. up/1 is the DELETE plus marker 184; down/1 restores and stamps 183.
  • expected_schema.ex diff is a @chain_hash restamp plus a comment block; objects/1 unchanged. V184 adds no table, column, index or constraint, so the restamp is the right mechanism (same as V182, commit 975f88f). The generator abort on sync_shop_*_slugs is reproduced on unmodified main and those functions are already excluded from the manifest since V171.
  • postgres.ex: @current_version 184, V184 entry marked latest, V183 entry kept.
  • Tests: v184_test.exs runs the real up_statements/1/down_statements/1 against a seeded row, including a hand-created EUR row surviving down. test/phoenix_kit/migrations/ + release_check test: 16 doctests, 448 tests, 0 failures. mix phoenix_kit.release_check: Migration Version Sync passes (V135..V184 contiguous, chain_hash matches 50 files); remaining items are feature-branch noise (CHANGELOG, branch, tag).
  • Commit by the author only; no version/CHANGELOG change.

Notes, not blockers

  • On the host's stand branch (this PR merged with upstream main and PR #782's sitemap commits), the full suite shows one order-dependent failure in admin_route_dedup_test.exs; it passes in isolation and its own moduledoc documents the parallel-compilation race. V184 touches only lib/phoenix_kit/migrations/, no route or module-discovery code.
  • mix test without a prior MIX_ENV=test mix compile --force did not compile test/support in this environment.

mdon added a commit to mdon/phoenix_kit that referenced this pull request Sep 6, 2026
…eir zone
A stored instant does not say which regime wrote it. When `time_zone`
moved from an integer offset to an IANA id (2.13.9) and five modules turned
out to have added that value to other instants, the rows they had written
could not be repaired: `phoenix_kit_settings.date_updated` holds the last
change only, no settings writer logged to the activity feed, and the feed
prunes after 90 days anyway. "What was this setting at that instant?" had
no answer.
`phoenix_kit_settings_history` records one row per settings write that
changes a value — the value before and after, the actor when a person made
it, a source, the time — and is never pruned. It is written at the query
layer inside the same transaction as the write, so every public writer
records (`update_setting`, the batch, the module and boolean forms, JSON
settings, the admin pages) and a write that leaves the value as it was
records nothing: saving the settings page does not produce a row per
field. A restricted (secret) setting records that a change happened with
both values withheld. The `actor_uuid` FK sets itself null when the account
goes; the row stays. Every writer takes `actor_uuid:` and `source:`; the
three admin settings pages pass the current user and `"settings"`.
Reading it: `Settings.history/2` (newest first) and `Settings.value_at/2`
— the newest change at or before the instant says what the value became;
with none, the oldest change after it says what it was before recording
began; with no history at all, the current value.
The same migration adds `phoenix_kit_posts.time_zone` (varchar(64),
nullable): the one core-owned table that stores a typed wall clock now
carries the zone it was typed in, so the row can be re-resolved on its own
(the posts module writes it). Rows written before hold nil.
The manifest declares the thirteen objects by hand from a database the
chain built; `chain_hash` restamped over 50 files; the four-file manifest
gate and the full suite with integration are green (one order-dependent
media-page flake passes alone, with and without this change). Migration
V184 collides with the open draft BeamLabEU#785's V184 — whichever merges second
renumbers, per AGENTS.md.
Not here: an admin view of the history, and the user's own timezone — the
activity feed already records `user_timezone_from`/`_to` on a profile
change, and the module rows carry their zone from now on.
@timujinne
timujinne marked this pull request as ready for review September 6, 2026 00:34
@ddon
ddon merged commit ef03efc into BeamLabEU:mainSep 6, 2026
mdon added a commit to mdon/phoenix_kit that referenced this pull request Sep 6, 2026
Upstream's BeamLabEU#785 took V184 (the dead shop_currency setting removed), so
this branch's activities/posts migration moves to V185: file, module,
marker, moduledoc entry, the manifest's three declarations and header
note; chain hash restamped over the 51 shipped files; the chain re-run
into a fresh database (V135→V185) and the full suite green.
ddon added a commit that referenced this pull request Sep 6, 2026
V185: currency-freeze columns on carts, cart items and orders (stacked on #785)
Sign up for freeto 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.

2 participants

@timujinne@ddon