~singpolyma/jmp-schemas

ref: 240b3444466fb458b517d84c83bd6a782a21934e jmp-schemas/deploy/customer_plans.sql -rw-r--r-- 238 bytes
240b3444Stephen Paul Weber NOTIFY on low balance 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- Deploy jmp:customer_plans to pg

BEGIN;

CREATE VIEW customer_plans AS
	SELECT DISTINCT ON (customer_id)
		customer_id,
		plan_name,
		expires_at
	FROM plan_log
	WHERE starts_at <= NOW()
	ORDER BY customer_id, starts_at DESC;

COMMIT;