koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/updater updatedatabase,1.54,1.55


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/updater updatedatabase,1.54,1.55
Date: Mon, 07 Jul 2003 08:36:16 -0700

Update of /cvsroot/koha/koha/updater
In directory sc8-pr-cvs1:/tmp/cvs-serv14616/updater

Modified Files:
        updatedatabase 
Log Message:
(again) fix to avoid errors when creating fields that are primary keys and a 
previous primary key exist.

Index: updatedatabase
===================================================================
RCS file: /cvsroot/koha/koha/updater/updatedatabase,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -r1.54 -r1.55
*** updatedatabase      7 Jul 2003 15:23:56 -0000       1.54
--- updatedatabase      7 Jul 2003 15:36:13 -0000       1.55
***************
*** 679,729 ****
  
  foreach $table ( keys %fielddefinitions ) {
!     print "Check table $table\n" if $debug;
!     $sth = $dbh->prepare("show columns from $table");
!     $sth->execute();
!     my $definitions;
!     while ( ( $column, $type, $null, $key, $default, $extra ) = 
$sth->fetchrow )
!     {
!         $definitions->{$column}->{type}    = $type;
!         $definitions->{$column}->{null}    = $null;
!         $definitions->{$column}->{key}     = $key;
!         $definitions->{$column}->{default} = $default;
!         $definitions->{$column}->{extra}   = $extra;
!     }    # while
!     my $fieldrow = $fielddefinitions{$table};
!     foreach my $row (@$fieldrow) {
!         my $field   = $row->{field};
!         my $type    = $row->{type};
!         my $null    = $row->{null};
!         my $key     = $row->{key};
!         my $default = $row->{default};
!         my $extra   = $row->{extra};
!         my $def     = $definitions->{$field};
!         unless ( $type eq $def->{type}
!             && $null eq $def->{null}
!             && $key eq $def->{key}
!             && $default eq $def->{default}
!             && $extra eq $def->{extra} )
!         {
! 
!             if ( $null eq '' ) {
!                 $null = 'NOT NULL';
!             }
!             if ( $key eq 'PRI' ) {
  # if it's a primary key, drop the previous pk, before altering the table
!                       $dbh->do("alter table $table drop primary key");
!                 $key = 'PRIMARY KEY';
!             }
!             unless ( $extra eq 'auto_increment' ) {
!                 $extra = '';
!             }
!             my $sth =
!               $dbh->prepare(
! "alter table $table change $field $field $type $null $key $extra default ?"
!             );
!             $sth->execute($default);
!             print "  Alter $field in $table\n";
!         }
!     }
  }
  
--- 679,729 ----
  
  foreach $table ( keys %fielddefinitions ) {
!       print "Check table $table\n" if $debug;
!       $sth = $dbh->prepare("show columns from $table");
!       $sth->execute();
!       my $definitions;
!       while ( ( $column, $type, $null, $key, $default, $extra ) = 
$sth->fetchrow )
!       {
!               $definitions->{$column}->{type}    = $type;
!               $definitions->{$column}->{null}    = $null;
!               $definitions->{$column}->{key}     = $key;
!               $definitions->{$column}->{default} = $default;
!               $definitions->{$column}->{extra}   = $extra;
!       }    # while
!       my $fieldrow = $fielddefinitions{$table};
!       foreach my $row (@$fieldrow) {
!               my $field   = $row->{field};
!               my $type    = $row->{type};
!               my $null    = $row->{null};
!               my $key     = $row->{key};
!               my $default = $row->{default};
!               my $extra   = $row->{extra};
!               my $def     = $definitions->{$field};
!               unless ( $type eq $def->{type}
!                       && $null eq $def->{null}
!                       && $key eq $def->{key}
!                       && $default eq $def->{default}
!                       && $extra eq $def->{extra} )
!               {
! 
!                       if ( $null eq '' ) {
!                               $null = 'NOT NULL';
!                       }
!                       if ( $key eq 'PRI' ) {
!                               $key = 'PRIMARY KEY';
!                       }
!                       unless ( $extra eq 'auto_increment' ) {
!                               $extra = '';
!                       }
  # if it's a primary key, drop the previous pk, before altering the table
!                       if ($key eq 'PRI') {
!                               my $sth =$dbh->prepare("alter table $table 
change $field $field $type $null $key $extra default ?");
!                       } else {
!                               my $sth =$dbh->prepare("alter table $table drop 
primary key, change $field $field $type $null $key $extra default ?");
!                       }
!                       $sth->execute($default);
!                       print "  Alter $field in $table\n";
!               }
!       }
  }
  
***************
*** 869,874 ****
  
  # $Log$
! # Revision 1.54  2003/07/07 15:23:56  tipaul
! # fix to avoid errors when creating fields that are primary keys and a 
previous primary key exist.
  #
  # Revision 1.53  2003/07/07 14:11:16  tipaul
--- 869,874 ----
  
  # $Log$
! # Revision 1.55  2003/07/07 15:36:13  tipaul
! # (again) fix to avoid errors when creating fields that are primary keys and 
a previous primary key exist.
  #
  # Revision 1.53  2003/07/07 14:11:16  tipaul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]