[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenonbeta/krecipes/src/DBBackend
From: Unai Garro <Unai.Garro () ee ! ed ! ac ! uk>
Date: 2003-09-25 19:49:36
[Download RAW message or body]
CVS commit by uga:
This is a fix to make the porting annma-compatible :)
The DB format changed in cvs, and as SQLite's format is not released it doesn't \
require any upgrades, so it doesn't port automatically. Now with this commit, one \
will be able to remove the db_info data, and the db will patch itself.
NOTE: this 'fix' will be removed before 0.4 is released, since it's not supposed to \
be necessary (SQLite format 0.3 didn't exist)
M +49 -3 literecipedb.cpp 1.40
--- kdenonbeta/krecipes/src/DBBackend/literecipedb.cpp #1.39:1.40
@@ -1125,4 +1125,50 @@ void LiteRecipeDB::portOldDatabases(floa
{
// This is the first SQLite version (0.4). There's no need to upgrade anything
+
+
+// FIXME: this code has to be removed before 0.4 is released. Just for temporal BC \
reasons Not necessary for 0.3, +// since 0.3 SQLite never existed :)
+
+if (version<0.4) // "Upgrade" to 0.4
+ {
+
+
+ // Missing indexes in the previous versions
+ QString command="CREATE index rid_index ON category_list(recipe_id)";
+ database->executeQuery(command);
+
+ command="CREATE index cid_index ON category_list(category_id)";
+ database->executeQuery(command);
+
+ command="CREATE index ridil_index ON ingredient_list(recipe_id)";
+ database->executeQuery(command);
+
+ command="CREATE index iidil_index ON ingredient_list(ingredient_id)";
+ database->executeQuery(command);
+
+ // Port data
+
+ //*1:: Recipes have always category -1 to speed up searches (no JOINs \
needed) + command="SELECT r.id FROM recipes r LEFT JOIN category_list cl ON \
r.id=cl.recipe_id WHERE cl.category_id IS NULL;"; // Find all recipes + \
QSQLiteResult recipesFound=database->executeQuery(command); +
+ if ( recipesFound.getStatus()!=QSQLiteResult::Failure ){
+ QSQLiteResultRow recipe=recipesFound.first();
+ while ( !recipesFound.atEnd() ) {
+ int recipeId=recipe.data(0).toInt();
+ QString cCommand=QString("INSERT INTO category_list VALUES \
(%1,-1);").arg(recipeId); + database->executeQuery(cCommand);
+ recipe=recipesFound.next();
+ }
+ }
+
+ // Set the version to the new one (0.4)
+
+ command="DELETE FROM db_info;"; // Remove previous version records if they \
exist + database->executeQuery(command);
+ command="INSERT INTO db_info VALUES(0.4,'Krecipes 0.3+(CVS)');"; // Set the \
new version + database->executeQuery(command);
+ }
+
}
@@ -1130,5 +1176,5 @@ float LiteRecipeDB::databaseVersion(void
{
-QString command="SELECT ver FROM db_info";
+QString command="SELECT ver FROM db_info;";
QSQLiteResult dbVersion=database->executeQuery(command);
@@ -1137,7 +1183,7 @@ QSQLiteResultRow row=dbVersion.first();
if (!dbVersion.atEnd())
return(row.data(0).toDouble());// There should be only one (or none \
for old DB) element, so go to first
- else return (0.4); // if table is empty, assume oldest (0.4), and port
+ else return (0.31); // if table is empty, assume oldest (0.4), and port \
//FIXME: put 0.4 before the release }
-else return(0.4); // By default go for oldest (0.4)
+else return(0.31); // By default go for oldest (0.4) // FIXME: put 0.4 here for the \
release }
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic