View | Details | Raw Unified | Return to bug 13007
Collapse All | Expand All

(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 2183-2189 CREATE TABLE `suggestions` ( -- purchase suggestions Link Here
2183
	total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
2183
	total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
2184
  PRIMARY KEY  (`suggestionid`),
2184
  PRIMARY KEY  (`suggestionid`),
2185
  KEY `suggestedby` (`suggestedby`),
2185
  KEY `suggestedby` (`suggestedby`),
2186
  KEY `managedby` (`managedby`)
2186
  KEY `managedby` (`managedby`),
2187
  CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE
2187
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2188
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2188
2189
2189
--
2190
--
(-)a/installer/data/mysql/updatedatabase.pl (+20 lines)
Lines 8781-8786 if ( CheckVersion($DBversion) ) { Link Here
8781
    SetVersion($DBversion);
8781
    SetVersion($DBversion);
8782
}
8782
}
8783
8783
8784
$DBversion = "3.17.00.XXX";
8785
if ( CheckVersion($DBversion) ) {
8786
    $dbh->do(q|
8787
        UPDATE suggestions s SET s.budgetid = NULL
8788
        WHERE NOT EXISTS (
8789
            SELECT NULL
8790
            FROM aqbudgets b
8791
            WHERE b.budget_id = s.budgetid
8792
        );
8793
    |);
8794
8795
    $dbh->do(q|
8796
        ALTER TABLE suggestions
8797
        ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE
8798
    |);
8799
8800
    print "Upgrade to $DBversion done (Bug 13007 - Add new foreign key suggestions.budgetid\n");
8801
    SetVersion($DBversion);
8802
}
8803
8784
=head1 FUNCTIONS
8804
=head1 FUNCTIONS
8785
8805
8786
=head2 TableExists($table)
8806
=head2 TableExists($table)
(-)a/t/db_dependent/Suggestions.t (-1 / +1 lines)
Lines 78-83 is( $suggestion->{publishercode}, $my_suggestion->{publishercode}, 'NewSuggestio Link Here
78
is( $suggestion->{suggestedby}, $my_suggestion->{suggestedby}, 'NewSuggestion stores the borrower number correctly' );
78
is( $suggestion->{suggestedby}, $my_suggestion->{suggestedby}, 'NewSuggestion stores the borrower number correctly' );
79
is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'NewSuggestion stores the biblio number correctly' );
79
is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'NewSuggestion stores the biblio number correctly' );
80
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' );
80
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' );
81
is( $suggestion->{budgetid}, undef, 'NewSuggestion should set budgetid to NULL if not given' );
81
82
82
is( CountSuggestion('ASKED'), 1, 'CountSuggestion returns the correct number of suggestions' );
83
is( CountSuggestion('ASKED'), 1, 'CountSuggestion returns the correct number of suggestions' );
83
84
84
- 

Return to bug 13007