diff options
| author | xengineering <me@xengineering.eu> | 2026-03-20 21:10:12 +0100 |
|---|---|---|
| committer | xengineering <me@xengineering.eu> | 2026-03-20 21:10:12 +0100 |
| commit | 09c34e0f373d48f5993598c76fa176c8ed2fd4cd (patch) | |
| tree | 40965dcb192a2d99e0e6a4e80162d9941b626c1d | |
| parent | 09330228991b73ede49ed186f74a2c4f306d2e20 (diff) | |
| download | sia-app-persistence.tar sia-app-persistence.tar.zst sia-app-persistence.zip | |
Add DB schema version checkpersistence
This version is only compatible with the schema version 0. No migrations
are implemented. Thus the DB is only accessed if the schema version
saved as user_version is as expected.
| -rw-r--r-- | lib/data.dart | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/data.dart b/lib/data.dart index 302908c..c9c8b4d 100644 --- a/lib/data.dart +++ b/lib/data.dart @@ -64,7 +64,13 @@ class AppState with ChangeNotifier { final Database db = sqlite3.open(dbPath); try { - final ResultSet result = db.select( + ResultSet result = db.select('PRAGMA user_version;'); + final int version = result.first.values.first as int; + if (version != 0) { + return; // DB schema version 0 required, no migrations implemented + } + + result = db.select( 'SELECT value FROM key_value WHERE key = \'server_fqdn\';' ); if (result.length == 1) { @@ -72,7 +78,7 @@ class AppState with ChangeNotifier { notifyListeners(); } } catch (e) { - // loading persistence is optional + return; } finally { db.close(); } |
