aboutsummaryrefslogtreecommitdiff
path: root/lib/model/db/db_extension.dart
diff options
context:
space:
mode:
authormirror <mirror@localhost>2026-11-22 08:41:00 +0900
committermirror <mirror@localhost>2026-11-22 08:41:00 +0900
commit449d8b74bd6d9dae98a07254cdfad677b920e7b0 (patch)
treec131c3528c4d517f56e19b854a7453fedb097d40 /lib/model/db/db_extension.dart
downloadaves-src-master.tar.gz
aves-src-master.zip
snapshot of aves v1.13.12 (secrets removed: android/app/google-services.json)HEADv1.13.12master
Diffstat (limited to 'lib/model/db/db_extension.dart')
-rw-r--r--lib/model/db/db_extension.dart13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/model/db/db_extension.dart b/lib/model/db/db_extension.dart
new file mode 100644
index 0000000..a0d2a66
--- /dev/null
+++ b/lib/model/db/db_extension.dart
@@ -0,0 +1,13 @@
+import 'package:sqflite/sqflite.dart';
+
+extension ExtraDatabase on Database {
+ // check table existence via `sqlite_master`
+ // `sqlite_schema` is the alias used in SQLite documentation,
+ // but it was introduced in SQLite v3.33.0 and it is unavailable on Android API < 34,
+ // and the historical alias `sqlite_master` is still supported.
+ // cf https://www.sqlite.org/faq.html#q7
+ Future<bool> tableExists(String table) async {
+ final results = await query('sqlite_master', where: 'type = ? AND name = ?', whereArgs: ['table', table]);
+ return results.isNotEmpty;
+ }
+}