~singpolyma/jmp-schemas

ref: 90c65e03df439876d7b8c22d0493151323e7b2df jmp-schemas/deploy/sub_cent_transactions.sql -rw-r--r-- 307 bytes
90c65e03Stephen Paul Weber Allow sub-cent transactions for minute billing 1 year, 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- Deploy jmp:sub_cent_transactions to pg

BEGIN;

DROP VIEW balances; -- Cannot alter column type while view exists

ALTER TABLE transactions ALTER COLUMN amount TYPE NUMERIC(12,4);

CREATE VIEW balances AS
	SELECT
		customer_id,
		SUM(amount) AS balance
	FROM transactions
	GROUP BY customer_id;

COMMIT;