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

(-)a/installer/data/mysql/atomicupdate/bug_21520.perl (-1 / +19 lines)
Lines 2-7 $DBversion = 'XXX'; # will be replaced by the RM Link Here
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
    $dbh->do( "ALTER TABLE oai_sets_mappings ADD COLUMN rule_order INT AFTER set_id, ADD COLUMN rule_operator VARCHAR(3) AFTER rule_order" );
3
    $dbh->do( "ALTER TABLE oai_sets_mappings ADD COLUMN rule_order INT AFTER set_id, ADD COLUMN rule_operator VARCHAR(3) AFTER rule_order" );
4
    $dbh->do( "UPDATE oai_sets_mappings SET rule_operator='or'" );
4
    $dbh->do( "UPDATE oai_sets_mappings SET rule_operator='or'" );
5
    my $sets = $dbh->selectall_arrayref("SELECT * from oai_sets_mappings ORDER BY set_id", { Slice => {} });
6
    my $i = 0;
7
    my $previous_set_id;
8
    for my $set ( @{$sets}) {
9
        my $set_id = $set->{set_id};
10
11
        if ($previous_set_id && $previous_set_id != $set_id) {
12
            $i = 0;
13
        }
14
15
        if ($i == 0) {
16
            $dbh->do("UPDATE oai_sets_mappings SET rule_operator=NULL WHERE set_id=? LIMIT 1", {}, $set_id);
17
        }
18
19
        $dbh->do("UPDATE oai_sets_mappings SET rule_order=? WHERE set_id=? AND rule_order IS NULL LIMIT 1", {}, $i, $set_id);
20
21
        $i++;
22
        $previous_set_id = $set_id;
23
    }
5
24
6
    # Always end with this (adjust the bug info)
25
    # Always end with this (adjust the bug info)
7
    SetVersion( $DBversion );
26
    SetVersion( $DBversion );
8
- 

Return to bug 21520