Changeset 10

Show
Ignore:
Timestamp:
04/06/05 19:18:53 (4 years ago)
Author:
ogawa
Message:

add Posgres support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mt-db-convert/trunk/mt-db-convert.cgi

    r1 r10  
    151151    } 
    152152 
     153    ## %ids will hold the highest IDs of each class. 
    153154    my %ids; 
    154155 
     
    177178        $ids{$class} = $o->id 
    178179          if !$ids{$class} || $o->id > $ids{$class}; 
    179  
     180        ## Look for duplicate template, category, and author names, 
     181        ## because we have uniqueness constraints in the DB. 
    180182        if ($class eq 'MT::Template') { 
    181183          my $key = lc($o->name) . $o->blog_id; 
     
    217219        } 
    218220 
    219  
    220221        $i++; 
    221222        print $o->save ? "." : "!<br />" . $o->errstr; 
     
    225226      print "</p>\n\n"; 
    226227    } 
     228 
     229    if ($type eq 'postgres') { 
     230        print "Updating sequences\n"; 
     231        my $dbh = MT::Object->driver->{dbh}; 
     232        for my $class (keys %ids) { 
     233            print "    $class => $ids{$class}\n"; 
     234            my $seq = 'mt_' . $class->datasource . '_' . 
     235                      $class->properties->{primary_key}; 
     236            $dbh->do("select setval('$seq', $ids{$class})") 
     237                or die $dbh->errstr; 
     238        } 
     239    } 
     240 
    227241  }; 
    228242