Show
Ignore:
Timestamp:
05/11/08 17:04:41 (4 years ago)
Author:
dom
Message:

fix much tab/whitespace damage; no functional changes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • wiki-toolkit/trunk/lib/Wiki/Toolkit/Setup/Pg.pm

    r426 r431  
    1414 
    1515my %create_sql = ( 
    16         schema_info => [ qq| 
     16    schema_info => [ qq| 
    1717CREATE TABLE schema_info ( 
    1818  version   integer      NOT NULL default 0 
     
    7575 
    7676my %upgrades = ( 
    77         old_to_8 => [ qq| 
     77    old_to_8 => [ qq| 
    7878CREATE SEQUENCE node_seq; 
    7979ALTER TABLE node ADD COLUMN id INTEGER; 
     
    9191ALTER TABLE content ADD COLUMN node_id INTEGER; 
    9292UPDATE content SET node_id =  
    93         (SELECT id FROM node where node.name = content.name) 
     93    (SELECT id FROM node where node.name = content.name) 
    9494|, qq| 
    9595DELETE FROM content WHERE node_id IS NULL; 
     
    103103ALTER TABLE metadata ADD COLUMN node_id INTEGER; 
    104104UPDATE metadata SET node_id =  
    105         (SELECT id FROM node where node.name = metadata.node) 
     105    (SELECT id FROM node where node.name = metadata.node) 
    106106|, qq| 
    107107DELETE FROM metadata WHERE node_id IS NULL; 
     
    192192    } 
    193193 
    194         # Do we need to upgrade the schema of existing tables? 
    195         # (Don't check if no tables currently exist) 
    196         my $upgrade_schema; 
    197         if(scalar keys %tables > 0) { 
    198                 $upgrade_schema = Wiki::Toolkit::Setup::Database::get_database_upgrade_required($dbh,$VERSION); 
    199         } else { 
    200                 print "Skipping schema upgrade check - no tables found\n"; 
    201         } 
    202  
    203         # Set up tables if not found 
     194    # Do we need to upgrade the schema of existing tables? 
     195    # (Don't check if no tables currently exist) 
     196    my $upgrade_schema; 
     197    if(scalar keys %tables > 0) { 
     198        $upgrade_schema = Wiki::Toolkit::Setup::Database::get_database_upgrade_required($dbh,$VERSION); 
     199    } else { 
     200        print "Skipping schema upgrade check - no tables found\n"; 
     201    } 
     202 
     203    # Set up tables if not found 
    204204    foreach my $required ( reverse sort keys %create_sql ) { 
    205205        if ( $tables{$required} ) { 
     
    213213    } 
    214214 
    215         # Do the upgrade if required 
    216         if($upgrade_schema) { 
    217                 print "Upgrading schema: $upgrade_schema\n"; 
    218                 my @updates = @{$upgrades{$upgrade_schema}}; 
    219                 foreach my $update (@updates) { 
    220                         if(ref($update) eq "CODE") { 
    221                                 &$update($dbh); 
    222                         } elsif(ref($update) eq "ARRAY") { 
    223                                 foreach my $nupdate (@$update) { 
    224                                         $dbh->do($nupdate); 
    225                                 } 
    226                         } else { 
    227                                 $dbh->do($update); 
    228                         } 
    229                 } 
    230         } 
     215    # Do the upgrade if required 
     216    if($upgrade_schema) { 
     217        print "Upgrading schema: $upgrade_schema\n"; 
     218        my @updates = @{$upgrades{$upgrade_schema}}; 
     219        foreach my $update (@updates) { 
     220            if(ref($update) eq "CODE") { 
     221                &$update($dbh); 
     222            } elsif(ref($update) eq "ARRAY") { 
     223                foreach my $nupdate (@$update) { 
     224                    $dbh->do($nupdate); 
     225                } 
     226            } else { 
     227                $dbh->do($update); 
     228            } 
     229        } 
     230    } 
    231231 
    232232    # Clean up if we made our own dbh. 
     
    300300        if ( $args{dbh} ) { 
    301301            return $args{dbh}; 
    302         } else { 
     302    } else { 
    303303            return _make_dbh( %args ); 
    304304        } 
     
    325325        if ( $args{dbh} ) { 
    326326            return 0; 
    327         } else { 
     327    } else { 
    328328            return 1; 
    329329        } 
     
    339339    $dsn .= ";host=$args{dbhost}" if $args{dbhost}; 
    340340    my $dbh = DBI->connect($dsn, $args{dbuser}, $args{dbpass}, 
    341                            { PrintError => 1, RaiseError => 1, 
    342                              AutoCommit => 1 } ) 
    343       or croak DBI::errstr; 
     341               { PrintError => 1, RaiseError => 1, 
     342                 AutoCommit => 1 } ) 
     343        or croak DBI::errstr; 
    344344    return $dbh; 
    345345}