Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE TABLE billing.receipts (
- id serial NOT NULL,
- payment_date DATE NOT NULL,
- "number" int4 NOT NULL,
- "comments" text NOT NULL,
- SUM NUMERIC(12,2) NOT NULL,
- STATUS int4 NOT NULL,
- payer VARCHAR(500) NOT NULL,
- proposed_agr int4 NULL,
- proposed_bill int4 NULL,
- process_result text NULL,
- payer_ok bool NOT NULL DEFAULT FALSE,
- CONSTRAINT receipts_pkey PRIMARY KEY (id),
- CONSTRAINT receipts_un UNIQUE (payment_date, NUMBER, comments, SUM),
- CONSTRAINT receipts_agreements_fk FOREIGN KEY (proposed_agr) REFERENCES agreements(id) ON UPDATE CASCADE ON DELETE RESTRICT,
- CONSTRAINT receipts_bills_fk FOREIGN KEY (proposed_bill) REFERENCES bills(id) ON UPDATE CASCADE ON DELETE SET NULL,
- CONSTRAINT receipts_status_fkey FOREIGN KEY (STATUS) REFERENCES aux.receipt_states(id)
- );
- CREATE INDEX receipts_proposed_agr_idx ON billing.receipts USING btree (proposed_agr);
- CREATE INDEX receipts_proposed_bill_idx ON billing.receipts USING btree (proposed_bill);
- CREATE INDEX receipts_status_idx ON billing.receipts USING btree (STATUS);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement