A deploy/customer_plans.sql => deploy/customer_plans.sql +14 -0
@@ 0,0 1,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;
A revert/customer_plans.sql => revert/customer_plans.sql +7 -0
@@ 0,0 1,7 @@
+-- Revert jmp:customer_plans from pg
+
+BEGIN;
+
+DROP VIEW customer_plans;
+
+COMMIT;
M sqitch.plan => sqitch.plan +1 -0
@@ 5,3 5,4 @@ transactions 2021-02-22T19:15:25Z Stephen Paul Weber <singpolyma@singpolyma.net>
balances 2021-02-23T15:08:09Z Stephen Paul Weber <singpolyma@singpolyma.net> # Creates a view to lookup customer balances
sub_cent_transactions 2021-02-24T01:37:35Z Stephen Paul Weber <singpolyma@singpolyma.net> # Minutes cost less than 1 cent, so we need more decimal places
plan_log 2021-02-24T01:53:29Z Stephen Paul Weber <singpolyma@singpolyma.net> # Log to show what plans an account has had
+customer_plans 2021-02-24T02:06:25Z Stephen Paul Weber <singpolyma@singpolyma.net> # View of current customer plans
A verify/customer_plans.sql => verify/customer_plans.sql +11 -0
@@ 0,0 1,11 @@
+-- Verify jmp:customer_plans on pg
+
+BEGIN;
+
+SELECT
+ customer_id,
+ plan_name,
+ expires_at
+FROM customer_plans;
+
+ROLLBACK;