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

(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 2212-2218 CREATE TABLE `suggestions` ( -- purchase suggestions Link Here
2212
   total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
2212
   total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
2213
  PRIMARY KEY  (`suggestionid`),
2213
  PRIMARY KEY  (`suggestionid`),
2214
  KEY `suggestedby` (`suggestedby`),
2214
  KEY `suggestedby` (`suggestedby`),
2215
  KEY `managedby` (`managedby`)
2215
  KEY `managedby` (`managedby`),
2216
  CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE
2216
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2217
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
2217
2218
2218
--
2219
--
(-)a/installer/data/mysql/updatedatabase.pl (+20 lines)
Lines 9669-9674 if ( CheckVersion($DBversion) ) { Link Here
9669
    SetVersion ($DBversion);
9669
    SetVersion ($DBversion);
9670
}
9670
}
9671
9671
9672
$DBversion = "3.19.00.XXX";
9673
if ( CheckVersion($DBversion) ) {
9674
    $dbh->do(q|
9675
        UPDATE suggestions s SET s.budgetid = NULL
9676
        WHERE NOT EXISTS (
9677
            SELECT NULL
9678
            FROM aqbudgets b
9679
            WHERE b.budget_id = s.budgetid
9680
        );
9681
    |);
9682
9683
    $dbh->do(q|
9684
        ALTER TABLE suggestions
9685
        ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE
9686
    |);
9687
9688
    print "Upgrade to $DBversion done (Bug 13007 - Add new foreign key suggestions.budgetid)\n";
9689
    SetVersion($DBversion);
9690
}
9691
9672
=head1 FUNCTIONS
9692
=head1 FUNCTIONS
9673
9693
9674
=head2 TableExists($table)
9694
=head2 TableExists($table)
(-)a/t/db_dependent/Suggestions.t (-2 / +3 lines)
Lines 24-30 use C4::Budgets; Link Here
24
24
25
use Koha::DateUtils qw( dt_from_string );
25
use Koha::DateUtils qw( dt_from_string );
26
26
27
use Test::More tests => 101;
27
use Test::More tests => 102;
28
use Test::Warn;
28
use Test::Warn;
29
29
30
BEGIN {
30
BEGIN {
Lines 114-119 is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'NewSuggestion Link Here
114
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' );
114
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' );
115
is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' );
115
is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' );
116
is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' );
116
is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' );
117
is( $suggestion->{budgetid}, undef, 'NewSuggestion should set budgetid to NULL if not given' );
118
117
is( CountSuggestion('ASKED'), 2, 'CountSuggestion returns the correct number of suggestions' );
119
is( CountSuggestion('ASKED'), 2, 'CountSuggestion returns the correct number of suggestions' );
118
120
119
121
120
- 

Return to bug 13007