731 lines
19 KiB
SQL
731 lines
19 KiB
SQL
--
|
|
-- PostgreSQL database dump
|
|
--
|
|
|
|
\restrict dcppwhgnHJoNOBlNPc2moWihaP892wdvcafOsrY89xMPWDOJABsPkfufznphBjh
|
|
|
|
-- Dumped from database version 17.7
|
|
-- Dumped by pg_dump version 17.7
|
|
|
|
SET statement_timeout = 0;
|
|
SET lock_timeout = 0;
|
|
SET idle_in_transaction_session_timeout = 0;
|
|
SET transaction_timeout = 0;
|
|
SET client_encoding = 'UTF8';
|
|
SET standard_conforming_strings = on;
|
|
SELECT pg_catalog.set_config('search_path', '', false);
|
|
SET check_function_bodies = false;
|
|
SET xmloption = content;
|
|
SET client_min_messages = warning;
|
|
SET row_security = off;
|
|
|
|
SET default_tablespace = '';
|
|
|
|
SET default_table_access_method = heap;
|
|
|
|
--
|
|
-- Name: customers; Type: TABLE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE TABLE public.customers (
|
|
id integer NOT NULL,
|
|
name character varying(255) NOT NULL,
|
|
city character varying(100),
|
|
state character varying(2),
|
|
zip_code character varying(10),
|
|
account_number character varying(50),
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
email character varying(255),
|
|
phone character varying(50),
|
|
phone2 character varying(50),
|
|
taxable boolean DEFAULT true,
|
|
line1 character varying(255),
|
|
line2 character varying(255),
|
|
line3 character varying(255),
|
|
line4 character varying(255),
|
|
qbo_id character varying(50),
|
|
qbo_sync_token character varying(50),
|
|
contact character varying(255),
|
|
remarks text
|
|
);
|
|
|
|
|
|
ALTER TABLE public.customers OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: customers_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE SEQUENCE public.customers_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.customers_id_seq OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: customers_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER SEQUENCE public.customers_id_seq OWNED BY public.customers.id;
|
|
|
|
|
|
--
|
|
-- Name: invoice_items; Type: TABLE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE TABLE public.invoice_items (
|
|
id integer NOT NULL,
|
|
invoice_id integer,
|
|
quantity character varying(20) NOT NULL,
|
|
description text NOT NULL,
|
|
rate character varying(50) NOT NULL,
|
|
amount character varying(50) NOT NULL,
|
|
item_order integer NOT NULL,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
qbo_item_id character varying(10) DEFAULT '9'::character varying,
|
|
unit_cost character varying(50)
|
|
);
|
|
|
|
ALTER TABLE public.invoice_items OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: invoice_items_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE SEQUENCE public.invoice_items_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.invoice_items_id_seq OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: invoice_items_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER SEQUENCE public.invoice_items_id_seq OWNED BY public.invoice_items.id;
|
|
|
|
|
|
--
|
|
-- Name: invoices; Type: TABLE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE TABLE public.invoices (
|
|
id integer NOT NULL,
|
|
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,
|
|
auth_code character varying(255),
|
|
tax_exempt boolean DEFAULT false,
|
|
tax_rate numeric(5,2) DEFAULT 8.25,
|
|
subtotal numeric(10,2) DEFAULT 0,
|
|
tax_amount numeric(10,2) DEFAULT 0,
|
|
total numeric(10,2) DEFAULT 0,
|
|
created_from_quote_id integer,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
qbo_id character varying(50),
|
|
qbo_sync_token character varying(50),
|
|
qbo_doc_number character varying(50),
|
|
paid_date date,
|
|
scheduled_send_date date,
|
|
payment_status character varying(20),
|
|
email_status character varying(20) DEFAULT 'open'::character varying,
|
|
bill_to_name character varying(255),
|
|
is_recurring boolean DEFAULT false,
|
|
recurring_interval character varying(20),
|
|
next_recurring_date date,
|
|
recurring_source_id integer,
|
|
stripe_payment_link_id character varying(255),
|
|
stripe_payment_link_url text,
|
|
stripe_payment_status character varying(50) DEFAULT 'pending'::character varying,
|
|
sent_dates date[] DEFAULT '{}'::date[]
|
|
);
|
|
|
|
|
|
ALTER TABLE public.invoices OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: invoices_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE SEQUENCE public.invoices_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.invoices_id_seq OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: invoices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER SEQUENCE public.invoices_id_seq OWNED BY public.invoices.id;
|
|
|
|
|
|
--
|
|
-- Name: payment_invoices; Type: TABLE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE TABLE public.payment_invoices (
|
|
id integer NOT NULL,
|
|
payment_id integer,
|
|
invoice_id integer,
|
|
amount numeric(12,2) NOT NULL
|
|
);
|
|
|
|
|
|
ALTER TABLE public.payment_invoices OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: payment_invoices_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE SEQUENCE public.payment_invoices_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.payment_invoices_id_seq OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: payment_invoices_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER SEQUENCE public.payment_invoices_id_seq OWNED BY public.payment_invoices.id;
|
|
|
|
|
|
--
|
|
-- Name: payments; Type: TABLE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE TABLE public.payments (
|
|
id integer NOT NULL,
|
|
payment_date date NOT NULL,
|
|
reference_number character varying(100),
|
|
payment_method character varying(50),
|
|
deposit_to_account character varying(200),
|
|
total_amount numeric(12,2) NOT NULL,
|
|
customer_id integer,
|
|
qbo_payment_id character varying(50),
|
|
notes text,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
|
|
ALTER TABLE public.payments OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: payments_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE SEQUENCE public.payments_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.payments_id_seq OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: payments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER SEQUENCE public.payments_id_seq OWNED BY public.payments.id;
|
|
|
|
|
|
--
|
|
-- Name: quote_items; Type: TABLE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE TABLE public.quote_items (
|
|
id integer NOT NULL,
|
|
quote_id integer,
|
|
quantity character varying(20) NOT NULL,
|
|
description text NOT NULL,
|
|
rate character varying(50) NOT NULL,
|
|
amount character varying(50) NOT NULL,
|
|
item_order integer NOT NULL,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
is_tbd boolean DEFAULT false,
|
|
qbo_item_id character varying(10) DEFAULT '9'::character varying
|
|
);
|
|
|
|
|
|
ALTER TABLE public.quote_items OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: quote_items_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE SEQUENCE public.quote_items_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.quote_items_id_seq OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: quote_items_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER SEQUENCE public.quote_items_id_seq OWNED BY public.quote_items.id;
|
|
|
|
|
|
--
|
|
-- Name: quotes; Type: TABLE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE TABLE public.quotes (
|
|
id integer NOT NULL,
|
|
quote_number character varying(50) NOT NULL,
|
|
customer_id integer,
|
|
quote_date date NOT NULL,
|
|
tax_exempt boolean DEFAULT false,
|
|
tax_rate numeric(5,2) DEFAULT 8.25,
|
|
subtotal numeric(10,2) DEFAULT 0,
|
|
tax_amount numeric(10,2) DEFAULT 0,
|
|
total numeric(10,2) DEFAULT 0,
|
|
has_tbd boolean DEFAULT false,
|
|
created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
updated_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP,
|
|
tbd_note text
|
|
);
|
|
|
|
|
|
ALTER TABLE public.quotes OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: quotes_id_seq; Type: SEQUENCE; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE SEQUENCE public.quotes_id_seq
|
|
AS integer
|
|
START WITH 1
|
|
INCREMENT BY 1
|
|
NO MINVALUE
|
|
NO MAXVALUE
|
|
CACHE 1;
|
|
|
|
|
|
ALTER SEQUENCE public.quotes_id_seq OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: quotes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: 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,
|
|
period_start date NOT NULL,
|
|
period_end date NOT NULL,
|
|
total_sales numeric(10,2),
|
|
nontaxable_sales numeric(10,2),
|
|
taxable_sales numeric(10,2),
|
|
tax_collected numeric(10,2),
|
|
adjustment_amount numeric(10,2) DEFAULT 0,
|
|
adjustment_reason text,
|
|
adjustment_account_id character varying(50),
|
|
adjustment_account_name character varying(200),
|
|
net_paid numeric(10,2),
|
|
bank_account_id character varying(50),
|
|
bank_account_name character varying(200),
|
|
sales_tax_payable_id character varying(50),
|
|
sales_tax_payable_name character varying(200),
|
|
qbo_journal_entry_id character varying(50),
|
|
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)
|
|
);
|
|
|
|
ALTER TABLE public.sales_tax_periods OWNER TO quoteuser;
|
|
|
|
--
|
|
-- Name: customers id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.customers ALTER COLUMN id SET DEFAULT nextval('public.customers_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: invoice_items id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoice_items ALTER COLUMN id SET DEFAULT nextval('public.invoice_items_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: invoices id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices ALTER COLUMN id SET DEFAULT nextval('public.invoices_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: payment_invoices id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_invoices ALTER COLUMN id SET DEFAULT nextval('public.payment_invoices_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: payments id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payments ALTER COLUMN id SET DEFAULT nextval('public.payments_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: quote_items id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.quote_items ALTER COLUMN id SET DEFAULT nextval('public.quote_items_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: quotes id; Type: DEFAULT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.quotes ALTER COLUMN id SET DEFAULT nextval('public.quotes_id_seq'::regclass);
|
|
|
|
|
|
--
|
|
-- Name: customers customers_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.customers
|
|
ADD CONSTRAINT customers_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: customers customers_qbo_id_key; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.customers
|
|
ADD CONSTRAINT customers_qbo_id_key UNIQUE (qbo_id);
|
|
|
|
|
|
--
|
|
-- Name: invoice_items invoice_items_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoice_items
|
|
ADD CONSTRAINT invoice_items_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: invoices invoices_invoice_number_key; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT invoices_invoice_number_key UNIQUE (invoice_number);
|
|
|
|
|
|
--
|
|
-- Name: invoices invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT invoices_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: payment_invoices payment_invoices_payment_id_invoice_id_key; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_invoices
|
|
ADD CONSTRAINT payment_invoices_payment_id_invoice_id_key UNIQUE (payment_id, invoice_id);
|
|
|
|
|
|
--
|
|
-- Name: payment_invoices payment_invoices_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_invoices
|
|
ADD CONSTRAINT payment_invoices_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: payments payments_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payments
|
|
ADD CONSTRAINT payments_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: quote_items quote_items_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.quote_items
|
|
ADD CONSTRAINT quote_items_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: quotes quotes_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.quotes
|
|
ADD CONSTRAINT quotes_pkey PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: quotes quotes_quote_number_key; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.quotes
|
|
ADD CONSTRAINT quotes_quote_number_key UNIQUE (quote_number);
|
|
|
|
|
|
--
|
|
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.settings
|
|
ADD CONSTRAINT settings_pkey PRIMARY KEY (key);
|
|
|
|
|
|
--
|
|
-- Name: idx_customers_qbo_id; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE UNIQUE INDEX idx_customers_qbo_id ON public.customers USING btree (qbo_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_invoice_items_invoice_id; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_invoice_items_invoice_id ON public.invoice_items USING btree (invoice_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_invoice_items_invoice_qbo; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_invoice_items_invoice_qbo ON public.invoice_items USING btree (invoice_id, qbo_item_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_invoices_created_from_quote; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_invoices_created_from_quote ON public.invoices USING btree (created_from_quote_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_invoices_customer_id; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_invoices_customer_id ON public.invoices USING btree (customer_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_invoices_invoice_number; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_invoices_invoice_number ON public.invoices USING btree (invoice_number);
|
|
|
|
|
|
--
|
|
-- Name: idx_invoices_paid_date; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_invoices_paid_date ON public.invoices USING btree (paid_date);
|
|
|
|
|
|
--
|
|
-- Name: idx_invoices_recurring; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_invoices_recurring ON public.invoices USING btree (is_recurring, next_recurring_date) WHERE (is_recurring = true);
|
|
|
|
|
|
--
|
|
-- Name: idx_invoices_scheduled_send_date; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_invoices_scheduled_send_date ON public.invoices USING btree (scheduled_send_date);
|
|
|
|
|
|
--
|
|
-- Name: idx_payment_invoices_invoice; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_payment_invoices_invoice ON public.payment_invoices USING btree (invoice_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_payment_invoices_payment; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_payment_invoices_payment ON public.payment_invoices USING btree (payment_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_payments_customer; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_payments_customer ON public.payments USING btree (customer_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_payments_date; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_payments_date ON public.payments USING btree (payment_date);
|
|
|
|
|
|
--
|
|
-- Name: idx_quote_items_quote_id; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_quote_items_quote_id ON public.quote_items USING btree (quote_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_quotes_customer_id; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_quotes_customer_id ON public.quotes USING btree (customer_id);
|
|
|
|
|
|
--
|
|
-- Name: idx_quotes_quote_number; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE INDEX idx_quotes_quote_number ON public.quotes USING btree (quote_number);
|
|
|
|
|
|
--
|
|
-- Name: uniq_recurring_source_invoice_date; Type: INDEX; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
CREATE UNIQUE INDEX uniq_recurring_source_invoice_date ON public.invoices USING btree (recurring_source_id, invoice_date) WHERE (recurring_source_id IS NOT NULL);
|
|
|
|
|
|
--
|
|
-- Name: invoice_items invoice_items_invoice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoice_items
|
|
ADD CONSTRAINT invoice_items_invoice_id_fkey FOREIGN KEY (invoice_id) REFERENCES public.invoices(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: invoices invoices_created_from_quote_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT invoices_created_from_quote_id_fkey FOREIGN KEY (created_from_quote_id) REFERENCES public.quotes(id);
|
|
|
|
|
|
--
|
|
-- Name: invoices invoices_customer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT invoices_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES public.customers(id);
|
|
|
|
|
|
--
|
|
-- Name: invoices invoices_recurring_source_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT invoices_recurring_source_id_fkey FOREIGN KEY (recurring_source_id) REFERENCES public.invoices(id);
|
|
|
|
|
|
--
|
|
-- Name: payment_invoices payment_invoices_invoice_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_invoices
|
|
ADD CONSTRAINT payment_invoices_invoice_id_fkey FOREIGN KEY (invoice_id) REFERENCES public.invoices(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: payment_invoices payment_invoices_payment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payment_invoices
|
|
ADD CONSTRAINT payment_invoices_payment_id_fkey FOREIGN KEY (payment_id) REFERENCES public.payments(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: payments payments_customer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.payments
|
|
ADD CONSTRAINT payments_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES public.customers(id);
|
|
|
|
|
|
--
|
|
-- Name: quote_items quote_items_quote_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.quote_items
|
|
ADD CONSTRAINT quote_items_quote_id_fkey FOREIGN KEY (quote_id) REFERENCES public.quotes(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: quotes quotes_customer_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: quoteuser
|
|
--
|
|
|
|
ALTER TABLE ONLY public.quotes
|
|
ADD CONSTRAINT quotes_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES public.customers(id);
|
|
|
|
|
|
--
|
|
-- PostgreSQL database dump complete
|
|
--
|
|
|
|
\unrestrict dcppwhgnHJoNOBlNPc2moWihaP892wdvcafOsrY89xMPWDOJABsPkfufznphBjh
|
|
|