new reports
This commit is contained in:
280
schema.sql
280
schema.sql
@@ -2,7 +2,7 @@
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
\restrict dcppwhgnHJoNOBlNPc2moWihaP892wdvcafOsrY89xMPWDOJABsPkfufznphBjh
|
||||
\restrict TsnkGh5w4Bqm8Rc90OFENmnWJzydLxev1gibhMKf2y6LGG5aXtdaN2AqdspAKnp
|
||||
|
||||
-- Dumped from database version 17.7
|
||||
-- Dumped by pg_dump version 17.7
|
||||
@@ -23,6 +23,47 @@ SET default_tablespace = '';
|
||||
|
||||
SET default_table_access_method = heap;
|
||||
|
||||
--
|
||||
-- Name: accounting_sync_log; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE TABLE public.accounting_sync_log (
|
||||
id integer NOT NULL,
|
||||
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
||||
action character varying(50) NOT NULL,
|
||||
entity_type character varying(50),
|
||||
entity_qbo_id character varying(50),
|
||||
status character varying(20) NOT NULL,
|
||||
request_excerpt text,
|
||||
response_excerpt text,
|
||||
user_id character varying(100)
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.accounting_sync_log OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: accounting_sync_log_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.accounting_sync_log_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER SEQUENCE public.accounting_sync_log_id_seq OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: accounting_sync_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.accounting_sync_log_id_seq OWNED BY public.accounting_sync_log.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: customers; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
@@ -47,7 +88,8 @@ CREATE TABLE public.customers (
|
||||
qbo_id character varying(50),
|
||||
qbo_sync_token character varying(50),
|
||||
contact character varying(255),
|
||||
remarks text
|
||||
remarks text,
|
||||
secondary_email character varying(255)
|
||||
);
|
||||
|
||||
|
||||
@@ -92,6 +134,7 @@ CREATE TABLE public.invoice_items (
|
||||
unit_cost character varying(50)
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.invoice_items OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
@@ -125,7 +168,7 @@ CREATE TABLE public.invoices (
|
||||
invoice_number character varying(50) DEFAULT NULL::character varying,
|
||||
customer_id integer,
|
||||
invoice_date date NOT NULL,
|
||||
terms character varying(100) DEFAULT 'Net 14'::character varying,
|
||||
terms character varying(100) DEFAULT 'Net 30'::character varying,
|
||||
auth_code character varying(255),
|
||||
tax_exempt boolean DEFAULT false,
|
||||
tax_rate numeric(5,2) DEFAULT 8.25,
|
||||
@@ -151,7 +194,9 @@ CREATE TABLE public.invoices (
|
||||
stripe_payment_link_url text,
|
||||
stripe_payment_status character varying(50) DEFAULT 'pending'::character varying,
|
||||
sent_dates date[] DEFAULT '{}'::date[],
|
||||
source character varying(20) DEFAULT 'native'
|
||||
worker character varying(100),
|
||||
source character varying(20) DEFAULT 'native'::character varying,
|
||||
qbo_payment_error text
|
||||
);
|
||||
|
||||
|
||||
@@ -257,6 +302,59 @@ ALTER SEQUENCE public.payments_id_seq OWNER TO quoteuser;
|
||||
ALTER SEQUENCE public.payments_id_seq OWNED BY public.payments.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: qbo_account_cache; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE TABLE public.qbo_account_cache (
|
||||
qbo_id character varying(50) NOT NULL,
|
||||
name character varying(255) NOT NULL,
|
||||
fully_qualified_name character varying(500),
|
||||
account_type character varying(50),
|
||||
account_sub_type character varying(100),
|
||||
classification character varying(50),
|
||||
current_balance numeric(14,2),
|
||||
currency character varying(10),
|
||||
active boolean DEFAULT true,
|
||||
sync_token character varying(50),
|
||||
cached_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.qbo_account_cache OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: qbo_cache_status; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE TABLE public.qbo_cache_status (
|
||||
cache_name character varying(50) NOT NULL,
|
||||
last_synced_at timestamp without time zone,
|
||||
last_sync_count integer,
|
||||
last_sync_error text
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.qbo_cache_status OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: qbo_vendor_cache; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE TABLE public.qbo_vendor_cache (
|
||||
qbo_id character varying(50) NOT NULL,
|
||||
display_name character varying(255) NOT NULL,
|
||||
company_name character varying(255),
|
||||
primary_email character varying(255),
|
||||
primary_phone character varying(50),
|
||||
active boolean DEFAULT true,
|
||||
sync_token character varying(50),
|
||||
cached_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.qbo_vendor_cache OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: quote_items; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
@@ -344,25 +442,12 @@ ALTER SEQUENCE public.quotes_id_seq OWNER TO quoteuser;
|
||||
ALTER SEQUENCE public.quotes_id_seq OWNED BY public.quotes.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: settings; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE TABLE public.settings (
|
||||
key character varying(100) NOT NULL,
|
||||
value text,
|
||||
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.settings OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: sales_tax_periods; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE TABLE public.sales_tax_periods (
|
||||
id serial NOT NULL,
|
||||
id integer NOT NULL,
|
||||
period_start date NOT NULL,
|
||||
period_end date NOT NULL,
|
||||
total_sales numeric(10,2),
|
||||
@@ -379,15 +464,57 @@ CREATE TABLE public.sales_tax_periods (
|
||||
sales_tax_payable_id character varying(50),
|
||||
sales_tax_payable_name character varying(200),
|
||||
qbo_journal_entry_id character varying(50),
|
||||
status character varying(20) DEFAULT 'open',
|
||||
booked_at timestamp without time zone,
|
||||
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
||||
CONSTRAINT sales_tax_periods_period_start_period_end_key UNIQUE (period_start, period_end)
|
||||
status character varying(20) DEFAULT 'open'::character varying
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.sales_tax_periods OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: sales_tax_periods_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.sales_tax_periods_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
ALTER SEQUENCE public.sales_tax_periods_id_seq OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: sales_tax_periods_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.sales_tax_periods_id_seq OWNED BY public.sales_tax_periods.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: settings; Type: TABLE; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE TABLE public.settings (
|
||||
key character varying(100) NOT NULL,
|
||||
value text,
|
||||
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
|
||||
ALTER TABLE public.settings OWNER TO quoteuser;
|
||||
|
||||
--
|
||||
-- Name: accounting_sync_log id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.accounting_sync_log ALTER COLUMN id SET DEFAULT nextval('public.accounting_sync_log_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: customers id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
@@ -437,6 +564,21 @@ ALTER TABLE ONLY public.quote_items ALTER COLUMN id SET DEFAULT nextval('public.
|
||||
ALTER TABLE ONLY public.quotes ALTER COLUMN id SET DEFAULT nextval('public.quotes_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: sales_tax_periods id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.sales_tax_periods ALTER COLUMN id SET DEFAULT nextval('public.sales_tax_periods_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: accounting_sync_log accounting_sync_log_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.accounting_sync_log
|
||||
ADD CONSTRAINT accounting_sync_log_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: customers customers_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
@@ -501,6 +643,30 @@ ALTER TABLE ONLY public.payments
|
||||
ADD CONSTRAINT payments_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: qbo_account_cache qbo_account_cache_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.qbo_account_cache
|
||||
ADD CONSTRAINT qbo_account_cache_pkey PRIMARY KEY (qbo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: qbo_cache_status qbo_cache_status_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.qbo_cache_status
|
||||
ADD CONSTRAINT qbo_cache_status_pkey PRIMARY KEY (cache_name);
|
||||
|
||||
|
||||
--
|
||||
-- Name: qbo_vendor_cache qbo_vendor_cache_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.qbo_vendor_cache
|
||||
ADD CONSTRAINT qbo_vendor_cache_pkey PRIMARY KEY (qbo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: quote_items quote_items_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
@@ -525,6 +691,22 @@ ALTER TABLE ONLY public.quotes
|
||||
ADD CONSTRAINT quotes_quote_number_key UNIQUE (quote_number);
|
||||
|
||||
|
||||
--
|
||||
-- Name: sales_tax_periods sales_tax_periods_period_start_period_end_key; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.sales_tax_periods
|
||||
ADD CONSTRAINT sales_tax_periods_period_start_period_end_key UNIQUE (period_start, period_end);
|
||||
|
||||
|
||||
--
|
||||
-- Name: sales_tax_periods sales_tax_periods_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY public.sales_tax_periods
|
||||
ADD CONSTRAINT sales_tax_periods_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
||||
--
|
||||
@@ -533,6 +715,27 @@ ALTER TABLE ONLY public.settings
|
||||
ADD CONSTRAINT settings_pkey PRIMARY KEY (key);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_accounting_sync_log_action; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE INDEX idx_accounting_sync_log_action ON public.accounting_sync_log USING btree (action);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_accounting_sync_log_created; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE INDEX idx_accounting_sync_log_created ON public.accounting_sync_log USING btree (created_at DESC);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_accounting_sync_log_qbo_id; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE INDEX idx_accounting_sync_log_qbo_id ON public.accounting_sync_log USING btree (entity_qbo_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_customers_qbo_id; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
@@ -624,6 +827,41 @@ CREATE INDEX idx_payments_customer ON public.payments USING btree (customer_id);
|
||||
CREATE INDEX idx_payments_date ON public.payments USING btree (payment_date);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_qbo_account_cache_active; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE INDEX idx_qbo_account_cache_active ON public.qbo_account_cache USING btree (active);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_qbo_account_cache_classification; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE INDEX idx_qbo_account_cache_classification ON public.qbo_account_cache USING btree (classification);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_qbo_account_cache_type; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE INDEX idx_qbo_account_cache_type ON public.qbo_account_cache USING btree (account_type);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_qbo_vendor_cache_active; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE INDEX idx_qbo_vendor_cache_active ON public.qbo_vendor_cache USING btree (active);
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_qbo_vendor_cache_name_lower; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
|
||||
CREATE INDEX idx_qbo_vendor_cache_name_lower ON public.qbo_vendor_cache USING btree (lower((display_name)::text));
|
||||
|
||||
|
||||
--
|
||||
-- Name: idx_quote_items_quote_id; Type: INDEX; Schema: public; Owner: quoteuser
|
||||
--
|
||||
@@ -728,5 +966,5 @@ ALTER TABLE ONLY public.quotes
|
||||
-- PostgreSQL database dump complete
|
||||
--
|
||||
|
||||
\unrestrict dcppwhgnHJoNOBlNPc2moWihaP892wdvcafOsrY89xMPWDOJABsPkfufznphBjh
|
||||
\unrestrict TsnkGh5w4Bqm8Rc90OFENmnWJzydLxev1gibhMKf2y6LGG5aXtdaN2AqdspAKnp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user