--
--

SET escape_string_warning = off;




--
-- Name: loan_payments; Type: TABLE; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE TABLE loan_payments (
    dkey integer DEFAULT nextval('seq_loan_payments_id'::regclass) NOT NULL,
    paydate character varying(21) DEFAULT NULL::character varying NOT NULL,
    contractkey integer DEFAULT 0 NOT NULL,
    pmstaffkey integer DEFAULT 0 NOT NULL,
    payment numeric DEFAULT 0.00 NOT NULL,
    notes character varying(255) DEFAULT NULL::character varying,
    type integer DEFAULT 0,
    usern character varying(50) DEFAULT '0'::character varying,
    tdate character varying(21) DEFAULT '0'::character varying,
    metpay integer DEFAULT 0,
    reference character varying(50) DEFAULT NULL::character varying,
    eft integer DEFAULT 0 NOT NULL,
    connection_string_oninsert character varying(100) DEFAULT NULL::character varying,
    tdate_native timestamp without time zone,
    paydate_native timestamp without time zone NOT NULL,
    connection_string_onupdate character varying(100) DEFAULT NULL::character varying,
    create_ts timestamp without time zone DEFAULT now() NOT NULL,
    update_ts timestamp without time zone,
    exported_to_excalibur integer DEFAULT 0 NOT NULL,
    reverse_of_payment_id integer,
    debit_payable_on_ts timestamp without time zone,
    created_by_bbrk_user_id integer,
    statement_sensor_enable integer DEFAULT 0 NOT NULL,
    reference_int bigint,
    statement_presentation_ts timestamp without time zone
);


ALTER TABLE bbrk.loan_payments OWNER TO mysqltest;

--
-- Name: loan_payments_pkey; Type: CONSTRAINT; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

ALTER TABLE ONLY loan_payments
    ADD CONSTRAINT loan_payments_pkey PRIMARY KEY (dkey);


--
-- Name: contractkey; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX contractkey ON loan_payments USING btree (contractkey);


--
-- Name: eft; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX eft ON loan_payments USING btree (eft);


--
-- Name: fk_lp_createuser; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX fk_lp_createuser ON loan_payments USING btree (created_by_bbrk_user_id);


--
-- Name: fk_lp_reverseoforiginal; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX fk_lp_reverseoforiginal ON loan_payments USING btree (reverse_of_payment_id);


--
-- Name: indx_lp_combo_contracttype; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_combo_contracttype ON loan_payments USING btree (contractkey, type);


--
-- Name: indx_lp_contractdatenat; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_contractdatenat ON loan_payments USING btree (contractkey, tdate_native);


--
-- Name: indx_lp_contractdebtpayablets; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_contractdebtpayablets ON loan_payments USING btree (contractkey, debit_payable_on_ts);


--
-- Name: indx_lp_contractpaydatenat; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_contractpaydatenat ON loan_payments USING btree (contractkey, paydate_native);


--
-- Name: indx_lp_contracttypepaytdate; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_contracttypepaytdate ON loan_payments USING btree (contractkey, type, payment, tdate_native);


--
-- Name: indx_lp_cts; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_cts ON loan_payments USING btree (create_ts);


--
-- Name: indx_lp_debtpayablets; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_debtpayablets ON loan_payments USING btree (debit_payable_on_ts);


--
-- Name: indx_lp_paydatenat; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_paydatenat ON loan_payments USING btree (paydate_native);


--
-- Name: indx_lp_reference; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_reference ON loan_payments USING btree (reference);


--
-- Name: indx_lp_spts; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_spts ON loan_payments USING btree (statement_presentation_ts);


--
-- Name: indx_lp_tdatenat; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_tdatenat ON loan_payments USING btree (tdate_native);


--
-- Name: indx_lp_typereference; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_lp_typereference ON loan_payments USING btree (type, reference);


--
-- Name: indx_pymt_contractexportexcal; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_pymt_contractexportexcal ON loan_payments USING btree (contractkey, exported_to_excalibur);


--
-- Name: indx_pymt_exportexcal; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX indx_pymt_exportexcal ON loan_payments USING btree (exported_to_excalibur);


--
-- Name: paydate; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX paydate ON loan_payments USING btree (paydate);


--
-- Name: payment; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX payment ON loan_payments USING btree (payment);


--
-- Name: type; Type: INDEX; Schema: bbrk; Owner: mysqltest; Tablespace: 
--

CREATE INDEX type ON loan_payments USING btree (type);


--
-- Name: tgr_loan_payments_after_delete; Type: TRIGGER; Schema: bbrk; Owner: mysqltest
--

CREATE TRIGGER tgr_loan_payments_after_delete
    AFTER DELETE ON loan_payments
    FOR EACH ROW
    EXECUTE PROCEDURE tgrf_loan_payments_after_delete();


--
-- Name: tgr_loan_payments_after_insert; Type: TRIGGER; Schema: bbrk; Owner: mysqltest
--

CREATE TRIGGER tgr_loan_payments_after_insert
    AFTER INSERT ON loan_payments
    FOR EACH ROW
    EXECUTE PROCEDURE tgrf_loan_payments_after_insert();


--
-- Name: tgr_loan_payments_before_insert; Type: TRIGGER; Schema: bbrk; Owner: mysqltest
--

CREATE TRIGGER tgr_loan_payments_before_insert
    BEFORE INSERT ON loan_payments
    FOR EACH ROW
    EXECUTE PROCEDURE tgrf_loan_payments_before_insert();


--
-- Name: tgr_loan_payments_before_update; Type: TRIGGER; Schema: bbrk; Owner: mysqltest
--

CREATE TRIGGER tgr_loan_payments_before_update
    BEFORE UPDATE ON loan_payments
    FOR EACH ROW
    EXECUTE PROCEDURE tgrf_loan_payments_before_update();


--
-- Name: fk_lp_contract; Type: FK CONSTRAINT; Schema: bbrk; Owner: mysqltest
--

ALTER TABLE ONLY loan_payments
    ADD CONSTRAINT fk_lp_contract FOREIGN KEY (contractkey) REFERENCES loan_contractn(loankey);


--
-- Name: fk_lp_createuser; Type: FK CONSTRAINT; Schema: bbrk; Owner: mysqltest
--

ALTER TABLE ONLY loan_payments
    ADD CONSTRAINT fk_lp_createuser FOREIGN KEY (created_by_bbrk_user_id) REFERENCES bbrk_user(bbrk_user_id);


--
-- Name: fk_lp_reverseoforiginal; Type: FK CONSTRAINT; Schema: bbrk; Owner: mysqltest
--

ALTER TABLE ONLY loan_payments
    ADD CONSTRAINT fk_lp_reverseoforiginal FOREIGN KEY (reverse_of_payment_id) REFERENCES loan_payments(dkey);


--
-- Name: loan_payments; Type: ACL; Schema: bbrk; Owner: mysqltest
--

REVOKE ALL ON TABLE loan_payments FROM PUBLIC;
REVOKE ALL ON TABLE loan_payments FROM mysqltest;
GRANT ALL ON TABLE loan_payments TO mysqltest;
GRANT SELECT ON TABLE loan_payments TO wfgsoftware;


--
--

