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;
2217
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2217
2218
2218
--
2219
--
(-)a/installer/data/mysql/updatedatabase.pl (+20 lines)
Lines 9534-9539 if( CheckVersion($DBversion) ){ Link Here
9534
    SetVersion($DBversion);
9534
    SetVersion($DBversion);
9535
}
9535
}
9536
9536
9537
$DBversion = "3.17.00.XXX";
9538
if ( CheckVersion($DBversion) ) {
9539
    $dbh->do(q|
9540
        UPDATE suggestions s SET s.budgetid = NULL
9541
        WHERE NOT EXISTS (
9542
            SELECT NULL
9543
            FROM aqbudgets b
9544
            WHERE b.budget_id = s.budgetid
9545
        );
9546
    |);
9547
9548
    $dbh->do(q|
9549
        ALTER TABLE suggestions
9550
        ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE
9551
    |);
9552
9553
    print "Upgrade to $DBversion done (Bug 13007 - Add new foreign key suggestions.budgetid)\n";
9554
    SetVersion($DBversion);
9555
}
9556
9537
=head1 FUNCTIONS
9557
=head1 FUNCTIONS
9538
9558
9539
=head2 TableExists($table)
9559
=head2 TableExists($table)
(-)a/t/db_dependent/Suggestions.t (-2 / +3 lines)
Lines 23-29 use C4::Letters; Link Here
23
23
24
use Koha::DateUtils qw( dt_from_string );
24
use Koha::DateUtils qw( dt_from_string );
25
25
26
use Test::More tests => 97;
26
use Test::More tests => 98;
27
use Test::Warn;
27
use Test::Warn;
28
28
29
BEGIN {
29
BEGIN {
Lines 85-90 is( $suggestion->{biblionumber}, $my_suggestion->{biblionumber}, 'NewSuggestion Link Here
85
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' );
85
is( $suggestion->{STATUS}, 'ASKED', 'NewSuggestion stores a suggestion with the status ASKED by default' );
86
is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' );
86
is( $suggestion->{managedby}, undef, 'NewSuggestion stores empty string as undef for non existent foreign key (integer)' );
87
is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' );
87
is( $suggestion->{manageddate}, undef, 'NewSuggestion stores empty string as undef for date' );
88
is( $suggestion->{budgetid}, undef, 'NewSuggestion should set budgetid to NULL if not given' );
89
88
is( CountSuggestion('ASKED'), 1, 'CountSuggestion returns the correct number of suggestions' );
90
is( CountSuggestion('ASKED'), 1, 'CountSuggestion returns the correct number of suggestions' );
89
91
90
92
91
- 

Return to bug 13007