ja_customers table:
CREATE TABLE
ja_customers
(
id BIGINT DEFAULT "nextval"('"ja_customers_id_seq"'::"regclass") NOT NULL,
clientid BIGINT DEFAULT 0 NOT NULL,
name_first CHARACTER VARYING(80) DEFAULT ''::CHARACTER VARYING,
name_last CHARACTER VARYING(80) DEFAULT ''::CHARACTER VARYING,
company CHARACTER VARYING(255) DEFAULT ''::CHARACTER VARYING,
businesstype CHARACTER VARYING(80) DEFAULT ''::CHARACTER VARYING,
position CHARACTER VARYING(80) DEFAULT ''::CHARACTER VARYING,
email CHARACTER VARYING(50) DEFAULT NULL::CHARACTER VARYING,
address CHARACTER VARYING(250),
suburb CHARACTER VARYING(250),
city CHARACTER VARYING(80),
phone CHARACTER VARYING(50) DEFAULT NULL::CHARACTER VARYING,
mobile CHARACTER VARYING(40) DEFAULT NULL::CHARACTER VARYING,
fax CHARACTER VARYING(40) DEFAULT NULL::CHARACTER VARYING,
mailing_address CHARACTER VARYING(250),
mailing_suburb CHARACTER VARYING(250),
mailing_city CHARACTER VARYING(80),
regdate BIGINT DEFAULT 0 NOT NULL,
notes "TEXT" DEFAULT ''::"text",
gps_lat NUMERIC(15,10),
gps_long NUMERIC(15,10),
hourlyrate NUMERIC(6,2) DEFAULT 0 NOT NULL,
onaccount SMALLINT DEFAULT 0 NOT NULL,
calc_mobile CHARACTER VARYING(20),
country_code NUMERIC(10,1),
client_code CHARACTER VARYING(50),
geocode_accuracy SMALLINT DEFAULT 0,
crm_accountid CHARACTER VARYING(20),
crm_update BOOLEAN,
deleted BOOLEAN DEFAULT false NOT NULL,
address_bldg CHARACTER VARYING(150),
schedule_key CHARACTER VARYING(255),
schedule_key_timestamp INTEGER,
login CHARACTER VARYING(30) DEFAULT ''::CHARACTER VARYING NOT NULL,
pass CHARACTER VARYING(50) DEFAULT ''::CHARACTER VARYING NOT NULL,
default_bill_customer BIGINT,
url CHARACTER VARYING(64),
postcode CHARACTER VARYING(20),
c_invoice_count INTEGER,
mailing_postcode CHARACTER VARYING(20),
created_date TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT "statement_timestamp"(),
modified_date TIMESTAMP(6) WITHOUT TIME ZONE DEFAULT "statement_timestamp"(),
created_userid INTEGER,
modified_userid INTEGER,
stpr CHARACTER VARYING(80),
mailing_stpr CHARACTER VARYING(80),
is_demo BOOLEAN DEFAULT false NOT NULL,
tax_aggregate_id_cost BIGINT,
tax_aggregate_id_price BIGINT,
job_share_mode SMALLINT DEFAULT 0 NOT NULL,
PRIMARY KEY (id),
CONSTRAINT fk_tax_aggregate_price_must_exist FOREIGN KEY (tax_aggregate_id_price)
REFERENCES db_live.dm.tax_aggregates (tax_aggregate_id),
CONSTRAINT fk_tax_aggregate_cost_must_exist FOREIGN KEY (tax_aggregate_id_cost) REFERENCES
db_live.dm.tax_aggregates (tax_aggregate_id),
CONSTRAINT fk_default_bill_customer_must_exist FOREIGN KEY (default_bill_customer)
REFERENCES ja_customers (id),
CONSTRAINT fk_account_must_exist FOREIGN KEY (clientid) REFERENCES ja_clients (id),
CONSTRAINT cc_gps_lat_and_long_must_come_together CHECK (("gps_long" IS NULL) = ("gps_lat"
IS NULL))
);