Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0e43d3cf

Von Moritz Bunkus vor mehr als 11 Jahren hinzugefügt

  • ID 0e43d3cfea2cfdb938490c8221048b235f754fd3
  • Vorgänger 3774d83b
  • Nachfolger 75906e88

Alten DB-Upgrademechnismus sql/Pg-upgrade entfernt

Unterschiede anzeigen:

SL/User.pm
114 114

  
115 115
  my $dbupdater = SL::DBUpgrade2->new(form => $form)->parse_dbupdate_controls;
116 116

  
117
  my $update_available = $dbupdater->update_available($dbversion) || $dbupdater->update2_available($dbh);
117
  my $update_available = $dbupdater->update2_available($dbh);
118 118
  $dbh->disconnect;
119 119

  
120 120
  return 0 if !$update_available;
......
140 140
  $SIG{HUP}  = 'IGNORE';
141 141
  $SIG{QUIT} = 'IGNORE';
142 142

  
143
  $self->dbupdate($form);
144 143
  $self->dbupdate2(form => $form, updater => $dbupdater, database => $::auth->client->{dbname});
145 144
  SL::DBUpgrade2->new(form => $::form, auth => 1)->apply_admin_dbupgrade_scripts(0);
146 145

  
......
373 372
  $main::lxdebug->leave_sub();
374 373
}
375 374

  
376
sub dbupdate {
377
  $main::lxdebug->enter_sub();
378

  
379
  my ($self, $form) = @_;
380

  
381
  local *SQLDIR;
382

  
383
  my @upgradescripts = ();
384
  my $query;
385
  my $rc = -2;
386

  
387
  if ($form->{dbupdate}) {
388

  
389
    # read update scripts into memory
390
    opendir(SQLDIR, "sql/Pg-upgrade")
391
      or &error("", "sql/Pg-upgrade : $!");
392
    @upgradescripts =
393
      sort(cmp_script_version
394
           grep(/Pg-upgrade-.*?\.(sql|pl)$/,
395
                readdir(SQLDIR)));
396
    closedir(SQLDIR);
397
  }
398

  
399
  my $dbupdater = SL::DBUpgrade2->new(form => $form);
400

  
401
  foreach my $db (split(/ /, $form->{dbupdate})) {
402

  
403
    next unless $form->{$db};
404

  
405
    # strip db from dataset
406
    $db =~ s/^db//;
407
    &dbconnect_vars($form, $db);
408

  
409
    my $dbh = SL::DBConnect->connect($form->{dbconnect}, $form->{dbuser}, $form->{dbpasswd}, SL::DBConnect->get_options)
410
      or $form->dberror;
411

  
412
    $dbh->do($form->{dboptions}) if ($form->{dboptions});
413

  
414
    # check version
415
    $query = qq|SELECT version FROM defaults|;
416
    my ($version) = selectrow_query($form, $dbh, $query);
417

  
418
    next unless $version;
419

  
420
    $version = calc_version($version);
421

  
422
    foreach my $upgradescript (@upgradescripts) {
423
      my $a = $upgradescript;
424
      $a =~ s/^Pg-upgrade-|\.(sql|pl)$//g;
425

  
426
      my ($mindb, $maxdb) = split /-/, $a;
427
      my $str_maxdb = $maxdb;
428
      $mindb = calc_version($mindb);
429
      $maxdb = calc_version($maxdb);
430

  
431
      next if ($version >= $maxdb);
432

  
433
      # if there is no upgrade script exit
434
      last if ($version < $mindb);
435

  
436
      # apply upgrade
437
      $main::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $upgradescript");
438
      $dbupdater->process_file($dbh, "sql/Pg-upgrade/$upgradescript", $str_maxdb);
439

  
440
      $version = $maxdb;
441

  
442
    }
443

  
444
    $rc = 0;
445
    $dbh->disconnect;
446

  
447
  }
448

  
449
  $main::lxdebug->leave_sub();
450

  
451
  return $rc;
452
}
453

  
454 375
sub dbupdate2 {
455 376
  $main::lxdebug->enter_sub();
456 377

  

Auch abrufbar als: Unified diff