Skip to content

Commit

Permalink
Update schema version
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Vicente committed Apr 11, 2014
1 parent 4bcf101 commit 0deb01b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
1 change: 0 additions & 1 deletion etc/default_data
@@ -1,4 +1,3 @@
INSERT INTO schemainfo (version) VALUES('1.0.5');

INSERT INTO circuittype (name) VALUES ('DS3');
INSERT INTO circuittype (name) VALUES ('xDSL');
Expand Down
15 changes: 9 additions & 6 deletions lib/DBUTIL.pm
Expand Up @@ -456,22 +456,25 @@ CREATE USER $CONFIG{DB_NETDOT_USER} WITH PASSWORD '$CONFIG{DB_NETDOT_PASS}' NOCR

sub insert_default_data{
my @data;

# Insert current schema version
# Get version number from library
my $version = `grep 'our \$VERSION' ../lib/Netdot.pm`;
chomp($version);
$version =~ s/.*\=\s+"(.*)";/$1/;
push @data, "INSERT INTO schemainfo (version) VALUES('$version');";

my $file = $CONFIG{DEFAULT_DATA};
if ( -f $file) {
print "Inserting default data\n";
open (DEFAULT, "<$file") or die "Can't open $file: $!";
foreach (<DEFAULT>) {
next unless ( /\w+/ );
if ( /INSERT INTO (\w+)/ ){
my $t = $1;
$t = lc($t);
s/INSERT INTO \w+/INSERT INTO $t/;
}
push @data, $_;
}
}else{
die "Can't find $file";
}
print "Inserting default data\n";
&db_query(\@data);
}

Expand Down
10 changes: 9 additions & 1 deletion upgrade/updatedb
Expand Up @@ -51,11 +51,14 @@ if ( $schema_version eq '1.0.1' ){

&upg_104_105();

}elsif ( $schema_version eq '1.0.5' ){

&upg_105_106();

}else{
die "Unsupported version for this upgrade: $schema_version\n";
}


&processdata(\@statements);
&dbdisconnect();

Expand Down Expand Up @@ -313,3 +316,8 @@ sub upg_104_105 {
push @statements, "UPDATE schemainfo SET version='1.0.5' WHERE id=1;";

}

#########################################################################
sub upg_105_106 {
push @statements, "UPDATE schemainfo SET version='1.0.6' WHERE id=1;",
}

0 comments on commit 0deb01b

Please sign in to comment.