-- Fetch all the Accounts belonging to the Vitally
-- account of a particular user.
SELECT *
FROM fiber.vitally_account
WHERE account_id = '{user.vitally_id}'
-- Fetch all the Accounts belonging to the Vitally
-- account of a particular user.
SELECT *
FROM fiber.vitally_account
WHERE account_id = '{user.vitally_id}'
Code
CREATE TABLE fiber.vitally_account (
id TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
account_id TEXT,
external_id TEXT,
name TEXT,
traits JSONB,
organization_id TEXT,
account_owner_id TEXT,
churned_at TIMESTAMP WITH TIME ZONE,
first_seen_timestamp TIMESTAMP WITH TIME ZONE,
last_seen_timestamp TIMESTAMP WITH TIME ZONE,
last_inbound_message_timestamp TIMESTAMP WITH TIME ZONE,
last_outbound_message_timestamp TIMESTAMP WITH TIME ZONE,
mrr DOUBLE PRECISION,
next_renewal_date TIMESTAMP WITH TIME ZONE,
trial_end_date TIMESTAMP WITH TIME ZONE,
users_count INT,
nps_detractor_count INT,
nps_passive_count INT,
nps_promoter_count INT,
nps_score INT,
health_score INT,
csm_id TEXT,
account_executive_id TEXT,
key_roles TEXT[],
segments JSONB
)
CREATE TABLE fiber.vitally_account (
id TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
account_id TEXT,
external_id TEXT,
name TEXT,
traits JSONB,
organization_id TEXT,
account_owner_id TEXT,
churned_at TIMESTAMP WITH TIME ZONE,
first_seen_timestamp TIMESTAMP WITH TIME ZONE,
last_seen_timestamp TIMESTAMP WITH TIME ZONE,
last_inbound_message_timestamp TIMESTAMP WITH TIME ZONE,
last_outbound_message_timestamp TIMESTAMP WITH TIME ZONE,
mrr DOUBLE PRECISION,
next_renewal_date TIMESTAMP WITH TIME ZONE,
trial_end_date TIMESTAMP WITH TIME ZONE,
users_count INT,
nps_detractor_count INT,
nps_passive_count INT,
nps_promoter_count INT,
nps_score INT,
health_score INT,
csm_id TEXT,
account_executive_id TEXT,
key_roles TEXT[],
segments JSONB
)
Model definition