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

(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 2188-2194 CREATE TABLE `suggestions` ( -- purchase suggestions Link Here
2188
   total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
2188
   total DECIMAL(28,6) default NULL, -- suggested total cost (price*quantity updated for currency)
2189
  PRIMARY KEY  (`suggestionid`),
2189
  PRIMARY KEY  (`suggestionid`),
2190
  KEY `suggestedby` (`suggestedby`),
2190
  KEY `suggestedby` (`suggestedby`),
2191
  KEY `managedby` (`managedby`)
2191
  KEY `managedby` (`managedby`),
2192
  CONSTRAINT `suggestions_budget_id_fk` FOREIGN KEY (`budgetid`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE SET NULL ON UPDATE CASCADE
2192
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2193
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
2193
2194
2194
--
2195
--
(-)a/installer/data/mysql/updatedatabase.pl (+20 lines)
Lines 8974-8979 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
8974
    SetVersion($DBversion);
8974
    SetVersion($DBversion);
8975
}
8975
}
8976
8976
8977
$DBversion = "3.17.00.XXX";
8978
if ( CheckVersion($DBversion) ) {
8979
    $dbh->do(q|
8980
        UPDATE suggestions s SET s.budgetid = NULL
8981
        WHERE NOT EXISTS (
8982
            SELECT NULL
8983
            FROM aqbudgets b
8984
            WHERE b.budget_id = s.budgetid
8985
        );
8986
    |);
8987
8988
    $dbh->do(q|
8989
        ALTER TABLE suggestions
8990
        ADD CONSTRAINT suggestions_budget_id_fk FOREIGN KEY (budgetid) REFERENCES aqbudgets(budget_id) ON DELETE SET NULL ON UPDATE CASCADE
8991
    |);
8992
8993
    print "Upgrade to $DBversion done (Bug 13007 - Add new foreign key suggestions.budgetid\n");
8994
    SetVersion($DBversion);
8995
}
8996
8977
=head1 FUNCTIONS
8997
=head1 FUNCTIONS
8978
8998
8979
=head2 TableExists($table)
8999
=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