Lines 9812-9818
if ( CheckVersion($DBversion) ) {
Link Here
|
9812 |
}); |
9812 |
}); |
9813 |
|
9813 |
|
9814 |
$dbh->do(" |
9814 |
$dbh->do(" |
9815 |
CREATE TABLE IF NOT EXISTS account_credits ( |
9815 |
CREATE TABLE account_credits ( |
9816 |
credit_id int(11) NOT NULL AUTO_INCREMENT, |
9816 |
credit_id int(11) NOT NULL AUTO_INCREMENT, |
9817 |
borrowernumber int(11) NOT NULL, |
9817 |
borrowernumber int(11) NOT NULL, |
9818 |
`type` varchar(255) NOT NULL, |
9818 |
`type` varchar(255) NOT NULL, |
Lines 9827-9837
if ( CheckVersion($DBversion) ) {
Link Here
|
9827 |
updated_on timestamp NULL DEFAULT NULL, |
9827 |
updated_on timestamp NULL DEFAULT NULL, |
9828 |
PRIMARY KEY (credit_id), |
9828 |
PRIMARY KEY (credit_id), |
9829 |
KEY borrowernumber (borrowernumber), |
9829 |
KEY borrowernumber (borrowernumber), |
9830 |
KEY branchcode (branchcode) |
9830 |
KEY branchcode (branchcode), |
|
|
9831 |
FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, |
9832 |
FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE |
9831 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
9833 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
9832 |
"); |
9834 |
"); |
|
|
9835 |
|
9833 |
$dbh->do(" |
9836 |
$dbh->do(" |
9834 |
CREATE TABLE IF NOT EXISTS account_debits ( |
9837 |
CREATE TABLE account_debits ( |
9835 |
debit_id int(11) NOT NULL AUTO_INCREMENT, |
9838 |
debit_id int(11) NOT NULL AUTO_INCREMENT, |
9836 |
borrowernumber int(11) NOT NULL DEFAULT '0', |
9839 |
borrowernumber int(11) NOT NULL DEFAULT '0', |
9837 |
itemnumber int(11) DEFAULT NULL, |
9840 |
itemnumber int(11) DEFAULT NULL, |
Lines 9852-9858
if ( CheckVersion($DBversion) ) {
Link Here
|
9852 |
KEY itemnumber (itemnumber), |
9855 |
KEY itemnumber (itemnumber), |
9853 |
KEY borrowernumber (borrowernumber), |
9856 |
KEY borrowernumber (borrowernumber), |
9854 |
KEY issue_id (issue_id), |
9857 |
KEY issue_id (issue_id), |
9855 |
KEY branchcode (branchcode) |
9858 |
KEY branchcode (branchcode), |
|
|
9859 |
FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, |
9860 |
FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE |
9856 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
9861 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
9857 |
"); |
9862 |
"); |
9858 |
|
9863 |
|
Lines 9866-9892
if ( CheckVersion($DBversion) ) {
Link Here
|
9866 |
created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
9871 |
created_on timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, |
9867 |
PRIMARY KEY (offset_id), |
9872 |
PRIMARY KEY (offset_id), |
9868 |
KEY fee_id (debit_id), |
9873 |
KEY fee_id (debit_id), |
9869 |
KEY payment_id (credit_id) |
9874 |
KEY payment_id (credit_id), |
|
|
9875 |
FOREIGN KEY (debit_id) REFERENCES account_debits (debit_id) ON DELETE CASCADE ON UPDATE CASCADE, |
9876 |
FOREIGN KEY (credit_id) REFERENCES account_credits (credit_id) ON DELETE CASCADE ON UPDATE CASCADE |
9870 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
9877 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8; |
9871 |
"); |
9878 |
"); |
9872 |
|
9879 |
|
9873 |
$dbh->do(" |
9880 |
$dbh->do(" |
9874 |
ALTER TABLE `account_credits` |
|
|
9875 |
ADD CONSTRAINT account_credits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, |
9876 |
ADD CONSTRAINT account_credits_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE; |
9877 |
"); |
9878 |
$dbh->do(" |
9879 |
ALTER TABLE `account_debits` |
9880 |
ADD CONSTRAINT account_debits_ibfk_1 FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE, |
9881 |
ADD CONSTRAINT account_debits_ibfk_2 FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE; |
9882 |
"); |
9883 |
$dbh->do(" |
9884 |
ALTER TABLE `account_offsets` |
9885 |
ADD CONSTRAINT account_offsets_ibfk_1 FOREIGN KEY (debit_id) REFERENCES account_debits (debit_id) ON DELETE CASCADE ON UPDATE CASCADE, |
9886 |
ADD CONSTRAINT account_offsets_ibfk_2 FOREIGN KEY (credit_id) REFERENCES account_credits (credit_id) ON DELETE CASCADE ON UPDATE CASCADE; |
9887 |
"); |
9888 |
|
9889 |
$dbh->do(" |
9890 |
ALTER TABLE borrowers ADD account_balance DECIMAL( 28, 6 ) NOT NULL; |
9881 |
ALTER TABLE borrowers ADD account_balance DECIMAL( 28, 6 ) NOT NULL; |
9891 |
"); |
9882 |
"); |
9892 |
|
9883 |
|
9893 |
- |
|
|