mirror of https://github.com/sipwise/db-schema.git
* add billing.contact.timezone column * add billing.v_subscriber_timezone view * add billing.v_contract_timezone view * add billing.v_reseller_timezone view Change-Id: I7f08c332f28877426991de59b848aa1b635e0b92changes/43/10943/7
parent
47e6bc99c1
commit
2b105bbb7f
@ -0,0 +1,7 @@
|
||||
USE billing;
|
||||
|
||||
ALTER TABLE contacts DROP timezone;
|
||||
|
||||
DROP VIEW v_subscriber_timezone;
|
||||
DROP VIEW v_contract_timezone;
|
||||
DROP VIEW v_reseller_timezone;
|
@ -0,0 +1,30 @@
|
||||
USE billing;
|
||||
|
||||
ALTER TABLE contacts ADD timezone VARCHAR(80) DEFAULT NULL;
|
||||
|
||||
CREATE OR REPLACE VIEW v_subscriber_timezone AS
|
||||
SELECT sc.id as contact_id, s.id as subscriber_id, s.uuid,
|
||||
COALESCE(sc.timezone, cc.timezone, rc.timezone) as name
|
||||
FROM voip_subscribers s
|
||||
LEFT OUTER JOIN contacts sc ON sc.id = s.contact_id
|
||||
JOIN contracts c ON c.id = s.contract_id
|
||||
JOIN contacts cc ON cc.id = c.contact_id
|
||||
JOIN resellers r ON r.id = cc.reseller_id
|
||||
JOIN contracts i ON i.id = r.contract_id
|
||||
JOIN contacts rc ON rc.id = i.contact_id;
|
||||
|
||||
CREATE OR REPLACE VIEW v_contract_timezone AS
|
||||
SELECT cc.id as contact_id, c.id as contract_id,
|
||||
COALESCE(cc.timezone, rc.timezone) as name
|
||||
FROM contracts c
|
||||
JOIN contacts cc ON cc.id = c.contact_id
|
||||
JOIN resellers r ON r.id = cc.reseller_id
|
||||
JOIN contracts i ON i.id = r.contract_id
|
||||
JOIN contacts rc ON rc.id = i.contact_id;
|
||||
|
||||
CREATE OR REPLACE VIEW v_reseller_timezone AS
|
||||
SELECT rc.id as contact_id, r.id as reseller_id,
|
||||
rc.timezone as name
|
||||
FROM resellers r
|
||||
JOIN contracts i ON i.id = r.contract_id
|
||||
JOIN contacts rc ON rc.id = i.contact_id;
|
Loading…
Reference in new issue