@chaos-overlords/storage 0.9.5 → 0.9.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -674
- package/NOTICE +9 -12
- package/README.md +1 -1
- package/dist/postgres/events.d.ts.map +1 -1
- package/dist/postgres/events.js +34 -1
- package/dist/postgres/events.js.map +1 -1
- package/dist/postgres/repositories.js +47 -7
- package/dist/postgres/repositories.js.map +1 -1
- package/dist/postgres/schema.d.ts +51 -0
- package/dist/postgres/schema.d.ts.map +1 -1
- package/dist/postgres/schema.js +24 -2
- package/dist/postgres/schema.js.map +1 -1
- package/dist/postgres/takeovers.d.ts.map +1 -1
- package/dist/postgres/takeovers.js +24 -1
- package/dist/postgres/takeovers.js.map +1 -1
- package/dist/shared/constraints.d.ts +9 -3
- package/dist/shared/constraints.d.ts.map +1 -1
- package/dist/shared/constraints.js +9 -3
- package/dist/shared/constraints.js.map +1 -1
- package/dist/shared/mappers.d.ts +2 -0
- package/dist/shared/mappers.d.ts.map +1 -1
- package/dist/shared/mappers.js +1 -0
- package/dist/shared/mappers.js.map +1 -1
- package/dist/sqlite/events.d.ts.map +1 -1
- package/dist/sqlite/events.js +34 -1
- package/dist/sqlite/events.js.map +1 -1
- package/dist/sqlite/repositories.js +49 -8
- package/dist/sqlite/repositories.js.map +1 -1
- package/dist/sqlite/schema.d.ts +53 -0
- package/dist/sqlite/schema.d.ts.map +1 -1
- package/dist/sqlite/schema.js +24 -2
- package/dist/sqlite/schema.js.map +1 -1
- package/dist/sqlite/takeovers.d.ts.map +1 -1
- package/dist/sqlite/takeovers.js +24 -1
- package/dist/sqlite/takeovers.js.map +1 -1
- package/migrations/postgres/0006_stiff_newton_destine.sql +22 -0
- package/migrations/postgres/meta/0006_snapshot.json +942 -0
- package/migrations/postgres/meta/_journal.json +7 -0
- package/migrations/sqlite/0006_flawless_bedlam.sql +22 -0
- package/migrations/sqlite/meta/0006_snapshot.json +891 -0
- package/migrations/sqlite/meta/_journal.json +7 -0
- package/package.json +5 -5
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
ALTER TABLE `match_events` ADD `dedupe_key` text;--> statement-breakpoint
|
|
2
|
+
CREATE UNIQUE INDEX `match_events_dedupe_idx` ON `match_events` (`match_id`,`dedupe_key`);--> statement-breakpoint
|
|
3
|
+
CREATE INDEX `match_events_type_idx` ON `match_events` (`match_id`,`type`,`seq`);--> statement-breakpoint
|
|
4
|
+
ALTER TABLE `takeover_prompts` ADD `announced_at` integer;--> statement-breakpoint
|
|
5
|
+
ALTER TABLE `turns` ADD `settled_at` integer;--> statement-breakpoint
|
|
6
|
+
CREATE INDEX `turns_settled_idx` ON `turns` (`status`,`settled_at`);--> statement-breakpoint
|
|
7
|
+
-- Backfill: an announcement logged before this column existed carries no key, so the first repeat
|
|
8
|
+
-- of it after the upgrade (the sweep finishing a seal whose successor never opened, say) would find
|
|
9
|
+
-- nothing under its key and log it a second time. The earliest event of each fact takes the key its
|
|
10
|
+
-- announcement is now published under; a fact the old code logged twice keeps its later copy unkeyed.
|
|
11
|
+
UPDATE `match_events` SET `dedupe_key` = 'turn.sealed:' || json_extract(`payload`, '$.turn') WHERE `dedupe_key` IS NULL AND `type` = 'turn.sealed' AND `seq` = (SELECT min(e.`seq`) FROM `match_events` e WHERE e.`match_id` = `match_events`.`match_id` AND e.`type` = 'turn.sealed' AND json_extract(e.`payload`, '$.turn') = json_extract(`match_events`.`payload`, '$.turn'));--> statement-breakpoint
|
|
12
|
+
UPDATE `match_events` SET `dedupe_key` = 'turn.confirmed:' || json_extract(`payload`, '$.turn') WHERE `dedupe_key` IS NULL AND `type` = 'turn.confirmed' AND `seq` = (SELECT min(e.`seq`) FROM `match_events` e WHERE e.`match_id` = `match_events`.`match_id` AND e.`type` = 'turn.confirmed' AND json_extract(e.`payload`, '$.turn') = json_extract(`match_events`.`payload`, '$.turn'));--> statement-breakpoint
|
|
13
|
+
UPDATE `match_events` SET `dedupe_key` = 'turn.desynced:' || json_extract(`payload`, '$.turn') WHERE `dedupe_key` IS NULL AND `type` = 'turn.desynced' AND `seq` = (SELECT min(e.`seq`) FROM `match_events` e WHERE e.`match_id` = `match_events`.`match_id` AND e.`type` = 'turn.desynced' AND json_extract(e.`payload`, '$.turn') = json_extract(`match_events`.`payload`, '$.turn'));--> statement-breakpoint
|
|
14
|
+
UPDATE `match_events` SET `dedupe_key` = 'match.statusChanged:finished' WHERE `dedupe_key` IS NULL AND `type` = 'match.statusChanged' AND json_extract(`payload`, '$.status') = 'finished' AND `seq` = (SELECT min(e.`seq`) FROM `match_events` e WHERE e.`match_id` = `match_events`.`match_id` AND e.`type` = 'match.statusChanged' AND json_extract(e.`payload`, '$.status') = 'finished');--> statement-breakpoint
|
|
15
|
+
-- Backfill: a prompt opened before this column existed was announced by the call that opened it.
|
|
16
|
+
-- Without a stamp it would read as still owing its announcement, and the next call to ask about
|
|
17
|
+
-- the seat would publish `match.takeoverVoteRequested` a second time.
|
|
18
|
+
UPDATE `takeover_prompts` SET `announced_at` = `opened_at` WHERE `announced_at` IS NULL;--> statement-breakpoint
|
|
19
|
+
-- Backfill: a turn confirmed before this column existed had its follow-ups run by the verdict that
|
|
20
|
+
-- confirmed it. Without a stamp every one of them would be handed to the sweep as a verdict cut
|
|
21
|
+
-- short, and `turn.confirmed` would be logged again for the whole history of every live match.
|
|
22
|
+
UPDATE `turns` SET `settled_at` = coalesce(`sealed_at`, unixepoch() * 1000) WHERE `status` = 'confirmed' AND `settled_at` IS NULL;
|