[Slim-Checkins] r11107 - in /trunk/server: Slim/Schema.pm
slimserver.pl
adrian at svn.slimdevices.com
adrian at svn.slimdevices.com
Thu Jan 4 11:34:52 PST 2007
Author: adrian
Date: Thu Jan 4 11:34:52 2007
New Revision: 11107
URL: http://svn.slimdevices.com?rev=11107&view=rev
Log:
Bug: N/A
Description: force a wipescan if the schema is updated (also added to
6.5 at 11102)
Note - this only really covers schema upgrades. Users downgrading are
likely to need to delete the database to get to the right schema
version, all we do is warn on downgrade at present.
Modified:
trunk/server/Slim/Schema.pm
trunk/server/slimserver.pl
Modified: trunk/server/Slim/Schema.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Schema.pm?rev=11107&r1=11106&r2=11107&view=diff
==============================================================================
--- trunk/server/Slim/Schema.pm (original)
+++ trunk/server/Slim/Schema.pm Thu Jan 4 11:34:52 2007
@@ -151,7 +151,7 @@
}
}
- $class->migrateDB;
+ my $update = $class->migrateDB;
# Load the DBIx::Class::Schema classes we've defined.
# If you add a class to the schema, you must add it here as well.
@@ -173,7 +173,7 @@
/);
# Build all our class accessors and populate them.
- for my $accessor (qw(lastTrackURL lastTrack trackAttrs driver)) {
+ for my $accessor (qw(lastTrackURL lastTrack trackAttrs driver schemaUpdated)) {
$class->mk_classaccessor($accessor);
}
@@ -189,6 +189,8 @@
$class->toggleDebug(logger('database.sql')->is_info);
$class->_buildValidHierarchies;
+
+ $class->schemaUpdated($update);
$initialized = 1;
}
@@ -370,9 +372,32 @@
'dir' => catdir(Slim::Utils::OSDetect::dirsFor('SQL'), $driver),
});
- $dbix->migrate;
-
- $log->info(sprintf("Connected to database $source - schema version: [%d]", $dbix->version));
+ my $old = $dbix->version || 0;
+
+ if ($dbix->migrate) {
+
+ my $new = $dbix->version || 0;
+
+ $log->info(sprintf("Connected to database $source - schema version: [%d]\n", $new));
+
+ if ($old != $new) {
+
+ $log->warn(sprintf("Migrated database from schema version: %d to version: %d\n", $old, $new));
+
+ return 1;
+
+ }
+
+ } else {
+
+ # this occurs if a user downgrades slimserver to a version with an older schema and which does not include
+ # the required downgrade sql scripts - should probably drop the whole database at this point
+
+ logError(sprintf("Unable to downgrade database from schema version: %d. You may need to delete the database.\n", $old));
+
+ }
+
+ return 0;
}
=head2 rs( $class )
Modified: trunk/server/slimserver.pl
URL: http://svn.slimdevices.com/trunk/server/slimserver.pl?rev=11107&r1=11106&r2=11107&view=diff
==============================================================================
--- trunk/server/slimserver.pl (original)
+++ trunk/server/slimserver.pl Thu Jan 4 11:34:52 2007
@@ -770,9 +770,9 @@
Slim::Utils::Prefs::set("audiodir",$audiodir);
}
- if (Slim::Schema->count('Track', { 'me.audio' => 1 }) == 0) {
-
- logWarning("No tracks in the database, initiating scan.");
+ if (Slim::Schema->schemaUpdated || Slim::Schema->count('Track', { 'me.audio' => 1 }) == 0) {
+
+ logWarning("Schema updated or tracks in the database, initiating scan.");
Slim::Control::Request::executeRequest(undef, ['wipecache']);
}
More information about the checkins
mailing list