banshee r3480 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Database



Author: gburt
Date: Tue Mar 18 22:06:16 2008
New Revision: 3480
URL: http://svn.gnome.org/viewvc/banshee?rev=3480&view=rev

Log:
2008-03-18  Gabriel Burt  <gabriel burt gmail com>

	* src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs:
	Forgot to make the db schema changes in the InitializeFreshDatabase method.


Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Database/BansheeDbFormatMigrator.cs	Tue Mar 18 22:06:16 2008
@@ -140,7 +140,7 @@
         }
         
         private void InnerMigrate ()
-        {   
+        {
             MethodInfo [] methods = GetType ().GetMethods (BindingFlags.Instance | BindingFlags.NonPublic);
             bool terminate = false;
             bool ran_migration_step = false;
@@ -171,8 +171,7 @@
                 }
             }
             
-            Execute (String.Format ("UPDATE CoreConfiguration SET Value = '{0}' WHERE Key = 'DatabaseVersion'",
-                CURRENT_VERSION));
+            Execute (String.Format ("UPDATE CoreConfiguration SET Value = {0} WHERE Key = 'DatabaseVersion'", CURRENT_VERSION));
         }
         
         protected bool TableExists(string tableName)
@@ -187,17 +186,11 @@
             
         protected int DatabaseVersion {
             get {
-                if(!TableExists("CoreConfiguration")) {
+                if (!TableExists("CoreConfiguration")) {
                     return 0;
                 }
                 
-                string select_query = @"
-                    SELECT Value 
-                        FROM CoreConfiguration
-                        WHERE Key = 'DatabaseVersion'
-                ";
-                
-                return Convert.ToInt32 (connection.Query<int> (select_query));
+                return connection.Query<int> ("SELECT Value FROM CoreConfiguration WHERE Key = 'DatabaseVersion'");
             }
         }
         
@@ -210,7 +203,7 @@
         
         [DatabaseVersion (1)]
         private bool Migrate_1 ()
-        {   
+        {
             if (TableExists("Tracks")) {
                 InitializeFreshDatabase ();
                 
@@ -280,12 +273,7 @@
                     Value               TEXT
                 )
             ");
-            
-            Execute (String.Format (
-                "INSERT INTO CoreConfiguration VALUES (null, 'DatabaseVersion', '{0}')",
-                CURRENT_VERSION
-            ));
-            
+            Execute (String.Format ("INSERT INTO CoreConfiguration VALUES (null, 'DatabaseVersion', {0})", CURRENT_VERSION));
             
             Execute(@"
                 CREATE TABLE CorePrimarySources (
@@ -379,6 +367,7 @@
             
             Execute(@"
                 CREATE TABLE CorePlaylists (
+                    PrimarySourceID     INTEGER,
                     PlaylistID          INTEGER PRIMARY KEY,
                     Name                TEXT,
                     SortColumn          INTEGER NOT NULL DEFAULT -1,
@@ -400,6 +389,7 @@
             
             Execute(@"
                 CREATE TABLE CoreSmartPlaylists (
+                    PrimarySourceID     INTEGER,
                     SmartPlaylistID     INTEGER PRIMARY KEY,
                     Name                TEXT NOT NULL,
                     Condition           TEXT,
@@ -522,6 +512,9 @@
                     SELECT * FROM SmartPlaylists
             ");
 
+            Execute ("UPDATE CoreSmartPlaylists SET PrimarySourceID = 1");
+            Execute ("UPDATE CorePlaylists SET PrimarySourceID = 1");
+
             ServiceManager.ServiceStarted += OnServiceStarted;
         }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]