~singpolyma/jmp-schemas

jmp-schemas/verify/plan_log_with_range.sql -rw-r--r-- 517 bytes
395bb797Stephen Paul Weber Tag for notify on top up an expired account a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- Verify jmp:plan_log_with_range on pg

BEGIN;

SELECT date_range::tsrange FROM plan_log;

INSERT INTO plan_log (customer_id, plan_name, date_range)
	VALUES ('cust', 'plan', '[2001-01-01, 2002-01-01]');

DO $$
BEGIN
	INSERT INTO plan_log (customer_id, plan_name, date_range)
		VALUES ('cust', 'plan', '[2001-11-01, 2001-12-01]');
	SELECT 1/0;
EXCEPTION WHEN exclusion_violation THEN
END $$;

INSERT INTO plan_log (customer_id, plan_name, date_range)
	VALUES ('cust2', 'plan', '[2001-01-01, 2002-01-01]');

ROLLBACK;