fix(db): own the two settings seeds, and repair the protocol-3 one-shot
Core seeded `game_account_signup` and `uo_link_protocol_3_migrated`, two keys that name a game concept. That made core's schema declare a module's settings, which is the structural half of what Phase 3 removes (MODULE_SYSTEM.md §2.7.1, slice 4). Both INSERTs move here. The keys are deliberately unchanged: they are live rows on every existing install and renaming one silently resets an operator's choice to the default. The marker is not just a tidy-up. It and the `UPDATE uo_link_config SET protocol = 3` it makes one-shot were adjacent in core's schema.sql until slice 1 moved the UPDATE here and left the INSERT behind — and the two files do not run together: core's schema is replayed in full before any module fragment. So the marker existed before the UPDATE ever read it, the NOT EXISTS guard was false on every boot of an upgraded install, and the migration could never fire. An install carrying a protocol-2 row would have stayed pinned at 2 against a v3 sidecar, 409ing every REST call — the exact failure the migration prevents. Latent rather than live: it bites only an install that first boots a post-slice-1 build while already holding a uo_link_config row, and `edge` has not cut over. `schemaFragment.test.js` asserts the order, plus the fragment rules core validates at load time (leading-verb allowlist, IF NOT EXISTS, grandfathered table prefixes) — restated here for the same reason manifest.test.js restates the manifest rules. Its statement splitter is a character walk, because a comment in this file contains quotes. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -21,7 +21,11 @@
|
||||
-- `notification_subs` rows for `shard.*` streams and `announce_job_legs` rows
|
||||
-- with leg `towncrier` belong to core's tables, and a module does not delete
|
||||
-- from those — core prunes them when it drops the registrations, which it can
|
||||
-- do because it knows which registrant owned what.
|
||||
-- do because it knows which registrant owned what. The two `settings` rows
|
||||
-- schema.sql seeds (`game_account_signup`, `uo_link_protocol_3_migrated`) are
|
||||
-- the same case with an extra reason: the second is a one-shot MIGRATION
|
||||
-- marker, and deleting it would re-arm a protocol bump against tables this
|
||||
-- file has just dropped.
|
||||
|
||||
DROP TABLE IF EXISTS `shard_atlas_pending`;
|
||||
DROP TABLE IF EXISTS `shard_atlas_meta`;
|
||||
|
||||
@@ -614,4 +614,31 @@ ALTER TABLE uo_link_config MODIFY COLUMN protocol INT NOT NULL DEFAULT 3;
|
||||
-- uo_link_config row yet) it is simply written with nothing to update.
|
||||
UPDATE uo_link_config SET protocol = 3
|
||||
WHERE id = 1 AND protocol < 3
|
||||
AND NOT EXISTS (SELECT 1 FROM settings WHERE `key` = 'uo_link_protocol_3_migrated');
|
||||
AND NOT EXISTS (SELECT 1 FROM settings WHERE `key` = 'uo_link_protocol_3_migrated');
|
||||
-- **The marker must be written HERE, not in core.** These two statements were
|
||||
-- adjacent in core's schema.sql before the extraction; slice 1 moved the UPDATE
|
||||
-- and left the INSERT behind, and the two files do not run at the same time —
|
||||
-- core's schema is replayed in full BEFORE any module fragment (MODULE_API.md
|
||||
-- §2.6). So the marker existed before the UPDATE ever read it, the NOT EXISTS
|
||||
-- was true on the first boot of a fresh install and false on every boot of an
|
||||
-- upgraded one, and the one-shot could never fire. An install carrying a
|
||||
-- protocol-2 row would have stayed pinned at 2 against a v3 sidecar — every
|
||||
-- REST call 409, which is precisely the failure this migration exists to
|
||||
-- prevent. Latent rather than live: it only bites an install that first boots a
|
||||
-- post-slice-1 build while already holding a uo_link_config row, and `edge` has
|
||||
-- not cut over yet.
|
||||
INSERT IGNORE INTO settings (`key`, value) VALUES ('uo_link_protocol_3_migrated', '1');
|
||||
|
||||
-- ── Settings rows this module owns ─────────────────────────────────────────
|
||||
--
|
||||
-- Both keys predate the module system and both name a game concept, so core
|
||||
-- seeding them made core's schema declare a module's settings — the structural
|
||||
-- half of what Phase 3 removes (MODULE_SYSTEM.md §2.7.1, slice 4). The KEYS are
|
||||
-- deliberately unchanged: they are live rows on every existing install, and
|
||||
-- renaming one would silently reset an operator's choice to the default.
|
||||
--
|
||||
-- INSERT IGNORE, so an install that already carries the row keeps its value and
|
||||
-- only a database that has never seen the key gets the default. Nothing in core
|
||||
-- reads either one; `game_account_signup` is read through ctx.settings by
|
||||
-- server/utils/gameSignup.js, which owns the policy.
|
||||
INSERT IGNORE INTO settings (`key`, value) VALUES ('game_account_signup', 'disabled');
|
||||
Reference in New Issue
Block a user