Improve/redesign ingredients #13
|
@ -487,18 +487,6 @@ void RecipeDatabase::ensureTablesExist(){
|
||||||
this->executeSQL("PRAGMA foreign_keys = ON;");
|
this->executeSQL("PRAGMA foreign_keys = ON;");
|
||||||
|
|
||||||
this->beginTransaction();
|
this->beginTransaction();
|
||||||
//Ingredients table.
|
|
||||||
this->executeSQL("CREATE TABLE IF NOT EXISTS ingredient("
|
|
||||||
"ingredientId INTEGER PRIMARY KEY,"
|
|
||||||
"foodGroup varchar,"
|
|
||||||
"name varchar UNIQUE);");
|
|
||||||
//Unit of Measure table.
|
|
||||||
this->executeSQL("CREATE TABLE IF NOT EXISTS unitOfMeasure("
|
|
||||||
"name varchar UNIQUE PRIMARY KEY,"
|
|
||||||
"plural varchar,"
|
|
||||||
"abbreviation varchar,"
|
|
||||||
"type int,"
|
|
||||||
"metricCoefficient real);");
|
|
||||||
//Recipe table. Each recipe can have at most one instruction, and one image.
|
//Recipe table. Each recipe can have at most one instruction, and one image.
|
||||||
this->executeSQL("CREATE TABLE IF NOT EXISTS recipe("
|
this->executeSQL("CREATE TABLE IF NOT EXISTS recipe("
|
||||||
"recipeId INTEGER PRIMARY KEY,"
|
"recipeId INTEGER PRIMARY KEY,"
|
||||||
|
@ -515,14 +503,9 @@ void RecipeDatabase::ensureTablesExist(){
|
||||||
"FOREIGN KEY (recipeId) REFERENCES recipe(recipeId));");
|
"FOREIGN KEY (recipeId) REFERENCES recipe(recipeId));");
|
||||||
//RecipeIngredient table.
|
//RecipeIngredient table.
|
||||||
this->executeSQL("CREATE TABLE IF NOT EXISTS recipeIngredient("
|
this->executeSQL("CREATE TABLE IF NOT EXISTS recipeIngredient("
|
||||||
"ingredientId int,"
|
|
||||||
"recipeId int,"
|
"recipeId int,"
|
||||||
"quantity real,"
|
"content,"
|
||||||
"unitName varchar,"
|
"FOREIGN KEY (recipeId) REFERENCES recipe(recipeId);");
|
||||||
"comment varchar,"
|
|
||||||
"FOREIGN KEY (ingredientId) REFERENCES ingredient(ingredientId),"
|
|
||||||
"FOREIGN KEY (recipeId) REFERENCES recipe(recipeId),"
|
|
||||||
"FOREIGN KEY (unitName) REFERENCES unitOfMeasure(name));");
|
|
||||||
this->commitTransaction();
|
this->commitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue