aboutsummaryrefslogtreecommitdiff
path: root/qlite/src/database.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2019-12-15 19:03:02 +0100
committerMarvin W <git@larma.de>2019-12-17 23:52:29 +0100
commita4a795af333d6bcf378e11df456a858af2fa4603 (patch)
tree4f0014f8b9b7876ffd35960beffe4d59fe41f53a /qlite/src/database.vala
parent97647f9b5251dfc7a5a84d7432a1914fa7ec66b9 (diff)
downloaddino-a4a795af333d6bcf378e11df456a858af2fa4603.tar.gz
dino-a4a795af333d6bcf378e11df456a858af2fa4603.zip
Use transaction for database migration
Diffstat (limited to 'qlite/src/database.vala')
-rw-r--r--qlite/src/database.vala10
1 files changed, 10 insertions, 0 deletions
diff --git a/qlite/src/database.vala b/qlite/src/database.vala
index d13b9bc4..f58b76b6 100644
--- a/qlite/src/database.vala
+++ b/qlite/src/database.vala
@@ -38,6 +38,11 @@ public class Database {
}
private void start_migration() {
+ try {
+ exec("BEGIN TRANSACTION");
+ } catch (Error e) {
+ error("SQLite error: %d - %s", db.errcode(), db.errmsg());
+ }
meta_table.create_table_at_version(expected_version);
long old_version = 0;
old_version = meta_table.row_with(meta_name, "version")[meta_int_val, -1];
@@ -66,6 +71,11 @@ public class Database {
foreach (Table t in tables) {
t.post();
}
+ try {
+ exec("END TRANSACTION");
+ } catch (Error e) {
+ error("SQLite error: %d - %s", db.errcode(), db.errmsg());
+ }
}
internal int errcode() {