1 Commits

Author SHA1 Message Date
3fbbcd5ffa migrations: fold the follow-up migrations back into init
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled
The payment-history indexes, the payment-logs order/step index and the
visa_master_order_actions table now live in init.{up,down}.sql, so the
folder is back to a single up/down pair. Databases that already ran the
removed migrations need `migrate force 20260702125108` once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:21:42 +05:00
8 changed files with 38 additions and 39 deletions

View File

@@ -2,6 +2,7 @@ DROP TABLE IF EXISTS payment_texts;
DROP TABLE IF EXISTS rbac_version;
DROP FUNCTION IF EXISTS rbac_bump_version() CASCADE;
DROP TABLE IF EXISTS visa_master_order_actions;
DROP TABLE IF EXISTS visa_master_payment_logs;
DROP TABLE IF EXISTS visa_master_order_payments;
DROP TABLE IF EXISTS payment_settings;

View File

@@ -622,6 +622,12 @@ CREATE INDEX IF NOT EXISTS visa_master_order_payments_order_id_idx ON visa_maste
CREATE INDEX IF NOT EXISTS visa_master_order_payments_user_id_idx ON visa_master_order_payments (user_id);
CREATE UNIQUE INDEX IF NOT EXISTS visa_master_order_payments_order_number_idx
ON visa_master_order_payments (order_number);
-- payment-history lists newest-first (ORDER BY p.id DESC) and is commonly
-- filtered to one gateway_status; without this, a rare status (e.g.
-- pending) means walking the whole primary key backwards to fill a page.
CREATE INDEX IF NOT EXISTS idx_visa_master_order_payments_status_id
ON visa_master_order_payments (gateway_status, id DESC)
WHERE deleted_at IS NULL;
-- Every individual step taken while processing a payout (validated, rate
-- fetched, gateway request sent, gateway response received, order marked
@@ -643,6 +649,37 @@ CREATE TABLE IF NOT EXISTS visa_master_payment_logs (
);
CREATE INDEX IF NOT EXISTS visa_master_payment_logs_order_id_idx ON visa_master_payment_logs (order_id);
-- payment-history reads each attempt's register/callback log rows
-- (formUrl, returnUrl, first callback) by order and step; without this
-- every row of a page scans all of its order's logs.
CREATE INDEX IF NOT EXISTS visa_master_payment_logs_order_step_idx
ON visa_master_payment_logs (order_id, step);
-- 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);
-- Admin-editable texts shown to clients around a visa/master/sber payout
-- (e.g. the warning before paying). Clients look a text up by its fixed

View File

@@ -1 +0,0 @@
DROP INDEX IF EXISTS idx_visa_master_order_payments_status_id;

View File

@@ -1,6 +0,0 @@
-- payment-history lists newest-first (ORDER BY p.id DESC) and is commonly
-- filtered to one gateway_status; without this, a rare status (e.g.
-- pending) means walking the whole primary key backwards to fill a page.
CREATE INDEX IF NOT EXISTS idx_visa_master_order_payments_status_id
ON visa_master_order_payments (gateway_status, id DESC)
WHERE deleted_at IS NULL;

View File

@@ -1 +0,0 @@
DROP INDEX IF EXISTS visa_master_payment_logs_order_step_idx;

View File

@@ -1,5 +0,0 @@
-- payment-history reads each attempt's register/callback log rows
-- (formUrl, returnUrl, first callback) by order and step; without this
-- every row of a page scans all of its order's logs.
CREATE INDEX IF NOT EXISTS visa_master_payment_logs_order_step_idx
ON visa_master_payment_logs (order_id, step);

View File

@@ -1 +0,0 @@
DROP TABLE IF EXISTS visa_master_order_actions;

View File

@@ -1,25 +0,0 @@
-- 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);