~singpolyma/jmp-schemas

6e5297af7e7f5064a1de72a5ade882e3168697c2 — Stephen Paul Weber 10 months ago e005a4d
Create table for cdr storage

Some of this data is not needed for billing (such as disposition, or full tel of
the other side vs a prefix) however it will be very useful if we expose call
logs to the user.  If this is a privacy concern we can allow users to request
deletion of CDRs from past billing periods in the future.
4 files changed, 42 insertions(+), 0 deletions(-)

A deploy/cdr.sql
A revert/cdr.sql
M sqitch.plan
A verify/cdr.sql
A deploy/cdr.sql => deploy/cdr.sql +19 -0
@@ 0,0 1,19 @@
-- Deploy jmp:cdr to pg

BEGIN;

CREATE TYPE call_direction AS ENUM ('inbound', 'outbound');

CREATE TABLE cdr (
	cdr_id      TEXT           PRIMARY KEY,
	customer_id TEXT           NOT NULL,
	start       TIMESTAMP      NOT NULL,
	billsec     INTEGER        NOT NULL,
	disposition TEXT           NOT NULL,
	tel         TEXT           NOT NULL, -- source or destination
	direction   call_direction NOT NULL DEFAULT('outbound')
);

CREATE INDEX ON cdr (customer_id);

COMMIT;

A revert/cdr.sql => revert/cdr.sql +7 -0
@@ 0,0 1,7 @@
-- Revert jmp:cdr from pg

BEGIN;

DROP TABLE cdr;

COMMIT;

M sqitch.plan => sqitch.plan +1 -0
@@ 6,3 6,4 @@ balances 2021-02-23T15:08:09Z Stephen Paul Weber <singpolyma@singpolyma.net> # C
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
cdr 2021-02-24T18:36:49Z Stephen Paul Weber <singpolyma@singpolyma.net> # Create CDR table for Asterisk

A verify/cdr.sql => verify/cdr.sql +15 -0
@@ 0,0 1,15 @@
-- Verify jmp:cdr on pg

BEGIN;

SELECT
	cdr_id,
	customer_id,
	start,
	billsec,
	disposition,
	tel,
	direction
FROM cdr;

ROLLBACK;