visamaster: record order actions for the "Ammallar" table
Every create, update and delete of a visa/master or sber order is now
recorded in visa_master_order_actions: who did it, finished or failed
(with the exception), and for an update only the columns that changed -
original before, changes after. Marking an order paid when a payment is
finalized is recorded the same way, with no user when the GBÜS callback
did it.
Actions are written in the transaction that changes the order, so one is
on record exactly when its change is; failed ones are written after the
rollback with the values they attempted. The payment finalize records
after its commit instead, so recording never holds up a payment GBÜS has
already taken. Updates that change nothing and creates that fail (no
order to attach to) are not recorded.
GET /visa-master-payment-orders/{id}/actions lists them, newest first;
GET /visa-master-payment-orders/{id}/actions/{actionId} adds original,
changes and exception. Both are staff-only and order-scoped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS visa_master_order_actions;
|
||||
@@ -0,0 +1,25 @@
|
||||
-- Every create/update/delete of a visa/master or sber order, for the
|
||||
-- order page's "Ammallar" table: who did it, whether it went through, and
|
||||
-- for an update only the columns that changed - original holds their
|
||||
-- values before, changes after. A create has no original and a delete no
|
||||
-- changes. Failed actions are kept too, with exception set and changes
|
||||
-- holding what was attempted. created_by is null when no user started it
|
||||
-- (the GBÜS callback finalizing a payment).
|
||||
CREATE TABLE IF NOT EXISTS visa_master_order_actions (
|
||||
id bigserial PRIMARY KEY,
|
||||
order_id bigint NOT NULL,
|
||||
name character varying(20) NOT NULL,
|
||||
status character varying(20) NOT NULL,
|
||||
original jsonb,
|
||||
changes jsonb,
|
||||
exception text,
|
||||
created_by bigint,
|
||||
created_at TIMESTAMP DEFAULT (CURRENT_TIMESTAMP AT TIME ZONE 'UTC') NOT NULL,
|
||||
CONSTRAINT visa_master_order_actions_order_id_fkey
|
||||
FOREIGN KEY (order_id) REFERENCES visa_master_payment_orders(id),
|
||||
CONSTRAINT visa_master_order_actions_created_by_fkey
|
||||
FOREIGN KEY (created_by) REFERENCES users(id)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS visa_master_order_actions_order_id_idx
|
||||
ON visa_master_order_actions (order_id, id DESC);
|
||||
Reference in New Issue
Block a user