fix: make payment event reduction monotonic
Quality / quality (ubuntu-latest) (push) Failing after 9m53s
Quality / quality (windows-latest) (push) Canceled after 0s

This commit is contained in:
Clintchiz committed 2026-08-23 21:34:59 +05:30
1 parent 98e0813061
commit fe44bc2091
11 files changed
+458 -16

No files matched your search

+14 -2
View File
@@ -19,12 +19,19 @@ DROP TABLE IF EXISTS wrn_payment_method;
DROP TABLE IF EXISTS wrn_payment_refund;
DROP TABLE IF EXISTS wrn_payment_event;
DROP TABLE IF EXISTS wrn_payment_intent;`;
const orderingMigration = `-- +up
ALTER TABLE wrn_payment_event ADD COLUMN occurred_at BIGINT;
ALTER TABLE wrn_payment_event ADD COLUMN gateway_sequence TEXT;
UPDATE wrn_payment_event SET occurred_at = created_at WHERE occurred_at IS NULL;
CREATE INDEX IF NOT EXISTS wrn_payment_event_gateway_order ON wrn_payment_event(intent_id, occurred_at, gateway_sequence, id);
-- +down
DROP INDEX IF EXISTS wrn_payment_event_gateway_order;`;
export function paymentPlugin() {
const key = "@wrnexus/payment:enabled";
return definePlugin({
name: "@wrnexus/payment",
version: "0.8.0",
version: "0.8.1",
componentDirs: [join(root, "components")],
routeEntries(context) {
return context.metadata.get(key)
@@ -45,7 +52,12 @@ export function paymentPlugin() {
throw new Error("WRN-PAYMENT-CONFIG: sandbox cannot be enabled in production");
},
migrations(context: PluginContext) {
return context.metadata.get(key) ? [{ id: "wrnexus-payment-001", source: migration }] : [];
return context.metadata.get(key)
? [
{ id: "wrnexus-payment-001", source: migration },
{ id: "wrnexus-payment-002-event-order", source: orderingMigration },
]
: [];
},
documentation: [join(root, "README.md")],
});