fix: make payment event reduction monotonic
This commit is contained in:
1 parent
98e0813061
commit
fe44bc2091
11 files changed
+458
-16
No files matched your search
@@ -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")],
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user