- fn update_to_next_version(version: i32, tx: &rusqlite::Transaction) -> Result<bool, DbError> {\r
- match version {\r
- 0 => {\r
- println!("Update to version 1...");\r
-\r
- // Initial structure.\r
- tx.execute_batch(\r
- "\r
- CREATE TABLE [Version] (\r
- [id] INTEGER PRIMARY KEY,\r
- [version] INTEGER NOT NULL UNIQUE,\r
- [datetime] INTEGER DATETIME\r
- );\r
-\r
- CREATE TABLE [Recipe] (\r
- [id] INTEGER PRIMARY KEY,\r
- [title] INTEGER NOT NULL,\r
- [description] INTEGER DATETIME\r
- );\r
- "\r
- )?;\r
-\r
- /*\r
- tx.execute(\r
- "\r
- INSERT INTO Version\r
- ",\r
- rusqlite::NO_PARAMS\r
- );*/\r
-\r
- Ok(true)\r
+ fn update_to_next_version(current_version: u32, tx: &rusqlite::Transaction) -> Result<bool, DBError> {\r
+ let next_version = current_version + 1;\r
+\r
+ if next_version <= CURRENT_DB_VERSION {\r
+ println!("Update to version {}...", next_version);\r
+ }\r
+\r
+ fn ok(updated: bool) -> Result<bool, DBError> {\r
+ if updated {\r
+ println!("Version updated");\r