[Slim-Checkins] r11134 - /branches/6.5/server/Slim/Schema.pm

adrian at svn.slimdevices.com adrian at svn.slimdevices.com
Sat Jan 6 11:24:40 PST 2007


Author: adrian
Date: Sat Jan  6 11:24:40 2007
New Revision: 11134

URL: http://svn.slimdevices.com?rev=11134&view=rev
Log:
Bug: N/A
Description: merge -r 11132:11133 from trunk to protect against schema downgrade

Modified:
    branches/6.5/server/Slim/Schema.pm

Modified: branches/6.5/server/Slim/Schema.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Slim/Schema.pm?rev=11134&r1=11133&r2=11134&view=diff
==============================================================================
--- branches/6.5/server/Slim/Schema.pm (original)
+++ branches/6.5/server/Slim/Schema.pm Sat Jan  6 11:24:40 2007
@@ -395,8 +395,21 @@
 	} 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
-		$::d_info && msgf("Unable to migrate database from schema version: %d\n", $old);
+		# the required downgrade sql scripts - attempt to drop and create the database at current schema version
+
+		$::d_info && msgf("Unable to downgrade database from schema version: %d - Attempting to recreate database\n", $old);
+
+		eval { $class->storage->dbh->do('DROP TABLE IF EXISTS dbix_migration') };
+
+		if ($dbix->migrate) {
+
+			$::d_info && msgf("Successfully created database at schema version: %d\n", $dbix->version);
+
+			return 1;
+
+		}
+
+		$::d_info && msgf("Unable to create database - **** You may need to manually delete the database ****\n", $old);
 
 	}
 



More information about the checkins mailing list