Skip to content
Snippets Groups Projects
Commit 4e314bb7 authored by Ian Longden's avatar Ian Longden
Browse files

version checking routines

parent d98e6bb6
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,37 @@ use Bio::Species;
# add well known meta info get-functions below
=head2 get_schema_version
Arg [1] : none
Example : $schema_ver = $meta_container->get_schema_version();
Description: Retrieves the schema version from the database meta table
Returntype : int
Exceptions : none
Caller : ?
Status : Medium risk
=cut
sub get_schema_version {
my $self = shift;
my $arrRef = $self->list_value_by_key( 'schema_version' );
if( @$arrRef ) {
my ($ver) = ($arrRef->[0] =~ /^\s*(\d+)\s*$/);
if(!defined($ver)){ # old style format
return 0;
}
return $ver;
} else {
$self->warn("Please insert meta_key 'schema_version' " .
"in meta table at core db.\n");
}
return 0;
}
=head2 get_Species
Arg [1] : none
......
......@@ -146,6 +146,9 @@ sub load_all{
# other wise it gets done again by the web initialisation stuff
delete $INC{$conf_file};
}
else{ #error message
print STDERR "File passed (".$conf_file.") does not exist therefore no configuration loaded\n";
}
}
elsif(defined($ENV{ENSEMBL_REGISTRY}) and -e $ENV{ENSEMBL_REGISTRY}){
my $file = $ENV{ENSEMBL_REGISTRY};
......@@ -847,7 +850,7 @@ sub load_registry_from_db{
for my $db (@dbnames){
if($db =~ /^([a-z]+_[a-z]+_[a-z]+)_(\d+)_(\d+[a-z]*)/){
if(defined($temp{$1})){
my ($r1,$r2) = split($temp{$1},"_");
my ($r1,$r2) = split("_",$temp{$1});
if($r1 < $2){
$temp{$1} = $2."_".$3;
}
......
......@@ -45,6 +45,8 @@ use Bio::EnsEMBL::DBSQL::DBAdaptor;
use Bio::EnsEMBL::Utils::Exception qw(warning throw deprecate stack_trace_dump);
my $SOFTWARE_VERSION = 34;
=head2 load_core, load_estgene, load_vega, load_compara, load_pipeline, load_SNP, load_lite
Arg [1] : DBAdaptor with DBConnection alredy attached
Returntype : DBAdaptor;
......@@ -244,8 +246,33 @@ sub load_and_attach_dnadb_to_core{
# those that do not need to attach to core:-#
sub check_version{
my ($dba) = @_;
# Check the datbase and versions match
# give warning if they do not.
my $mca = $dba->get_MetaContainerAdaptor();
my $database_version = $mca->get_schema_version();
if($database_version == 0){
#try to work out the version
if($dba->dbc->dbname() =~ /\S+_\S+_\S+_(\d+)_\S+/){
$database_version = $1;
}
else{
warn("No database version for database ".$dba->dbc->dbname().". You must be using as pre version 34 database with version 34 or later code. You need to update your database or use the appropriate ensembl software release to ensure your script does not crash\n");
}
}
if($database_version != $SOFTWARE_VERSION){
warn("For ".$dba->dbc->dbname()." there is a difference in the software release (".$SOFTWARE_VERSION.") and the database release (".$database_version."). You should change one of these to ensure your script does not crash.\n");
}
}
sub load_core{
load_adaptors(@_);
my ($dba) = @_;
load_adaptors($dba);
check_version($dba);
}
sub load_compara{
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment