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.56,1.57


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/updater updatedatabase,1.56,1.57
Date: Fri, 11 Jul 2003 04:50:31 -0700

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

Modified Files:
        updatedatabase 
Log Message:
fixing a bug that occured when adding a field into a table.

Index: updatedatabase
===================================================================
RCS file: /cvsroot/koha/koha/updater/updatedatabase,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -r1.56 -r1.57
*** updatedatabase      7 Jul 2003 15:37:20 -0000       1.56
--- updatedatabase      11 Jul 2003 11:50:29 -0000      1.57
***************
*** 560,564 ****
              null    => '',
              key     => 'PRI',
!             default => 'auto_increment'
          },
      ],
--- 560,565 ----
              null    => '',
              key     => 'PRI',
!                 default =>'',
!             extra => 'auto_increment'
          },
      ],
***************
*** 573,576 ****
--- 574,595 ----
          },
      ],
+       marc_breeding => [
+         {
+             field   => 'z3950random',
+             type    => 'varchar(40)',
+             null    => '',
+             key     => '',
+             default => '',
+             extra   => ''
+         },
+         {
+             field   => 'encoding',
+             type    => 'varchar(40)',
+             null    => '',
+             key     => '',
+             default => '',
+             extra   => ''
+         },
+     ],
  );
  
***************
*** 698,701 ****
--- 717,721 ----
                my $key     = $row->{key};
                my $default = $row->{default};
+               $default="''" unless $default;
                my $extra   = $row->{extra};
                my $def     = $definitions->{$field};
***************
*** 716,725 ****
                                $extra = '';
                        }
  # if it's a primary key, drop the previous pk, before altering the table
                        my $sth;
!                       if ($key eq 'PRI') {
!                               $sth =$dbh->prepare("alter table $table change 
$field $field $type $null $key $extra default ?");
                        } else {
!                               $sth =$dbh->prepare("alter table $table drop 
primary key, change $field $field $type $null $key $extra default ?");
                        }
                        $sth->execute($default);
--- 736,752 ----
                                $extra = '';
                        }
+                       # if it's a new column use "add", if it's an old one, 
use "change".
+                       my $action;
+                       if ($definitions->{$field}->{type}) {
+                               $action="change $field"
+                       } else {
+                               $action="add";
+                       }
  # if it's a primary key, drop the previous pk, before altering the table
                        my $sth;
!                       if ($key ne 'PRIMARY KEY') {
!                               $sth =$dbh->prepare("alter table $table $action 
$field $type $null $key $extra default ?");
                        } else {
!                               $sth =$dbh->prepare("alter table $table drop 
primary key, $action $field $type $null $key $extra default ?");
                        }
                        $sth->execute($default);
***************
*** 870,873 ****
--- 897,903 ----
  
  # $Log$
+ # Revision 1.57  2003/07/11 11:50:29  tipaul
+ # fixing a bug that occured when adding a field into a table.
+ #
  # Revision 1.56  2003/07/07 15:37:20  tipaul
  # *** empty log message ***




reply via email to

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