open database

This commit is contained in:
Alex
2024-09-04 08:58:30 -05:00
parent 6f37ab6a9e
commit 94e315c845
4 changed files with 27 additions and 2 deletions
+2
View File
@@ -9,6 +9,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:immich_mobile/extensions/build_context_extensions.dart';
import 'package:immich_mobile/utils/sqlite.dart';
import 'package:timezone/data/latest.dart';
import 'package:immich_mobile/constants/locales.dart';
import 'package:immich_mobile/services/background.service.dart';
@@ -54,6 +55,7 @@ void main() async {
Future<void> initApp() async {
await EasyLocalization.ensureInitialized();
await openSqliteDatabase();
if (kReleaseMode && Platform.isAndroid) {
try {
+22
View File
@@ -0,0 +1,22 @@
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
Future<void> openSqliteDatabase() async {
final database = openDatabase(
// Set the path to the database. Note: Using the `join` function from the
// `path` package is best practice to ensure the path is correctly
// constructed for each platform.
join(await getDatabasesPath(), 'immich_database.db'),
// When the database is first created, create a table to store dogs.
onCreate: (db, version) {
// Run the CREATE TABLE statement on the database.
return db.execute(
'CREATE TABLE dogs(id INTEGER PRIMARY KEY, name TEXT, age INTEGER)',
);
},
// Set the version. This executes the onCreate function and provides a
// path to perform database upgrades and downgrades.
version: 1,
);
}