From 0d6920540b289a59b021a6be86445279b39a26ef Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 17 Feb 2006 08:50:07 +0000 Subject: [PATCH] Automatische Datenbankupgrades. Einfach upgrade Datei ins sql/ Verzeichnis legen, einloggen, fertig. SL/Form.pm::dbversion ist nicht mehr noetig. [r806:808 aus LINET prog-Repo] --- SL/Form.pm | 1 - SL/User.pm | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/SL/Form.pm b/SL/Form.pm index 90f412018..3c0e2e6bb 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -143,7 +143,6 @@ sub new { $self->{action} =~ s/( |-|,|#)/_/g; $self->{version} = "2.2.0"; - $self->{dbversion} = "2.2.0"; $main::lxdebug->leave_sub(); diff --git a/SL/User.pm b/SL/User.pm index f989e86f5..fbc022357 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -162,7 +162,7 @@ sub login { $rc = 0; - if ($form->{dbversion} ne $dbversion) { + if (&update_available($dbversion)) { # update the tables open FH, ">$userspath/nologin" or die " @@ -652,6 +652,16 @@ sub cmp_script_version { } ## /LINET +sub update_available { + ($cur_version) = @_; + opendir SQLDIR, "sql/." or &error("", "$!"); + my @upgradescripts = + grep(/$form->{dbdriver}-upgrade-$cur_version.*\.sql/, readdir(SQLDIR)); + closedir SQLDIR; + + return ($#upgradescripts > -1); +} + sub dbupdate { $main::lxdebug->enter_sub(); -- 2.20.1