Line data Source code
1 : import 'dart:io';
2 :
3 : import 'package:drift/drift.dart';
4 : import 'package:drift/native.dart';
5 : import 'package:network_tools/network_tools.dart';
6 : import 'package:network_tools/src/models/drift/arp_data.dart';
7 : import 'package:network_tools/src/models/drift/vendor_data.dart';
8 : import 'package:path/path.dart' as path;
9 : part 'drift_database.g.dart';
10 :
11 : @DriftDatabase(tables: [ARPDrift, VendorDrift])
12 : class AppDatabase extends _$AppDatabase {
13 : // After generating code, this class needs to define a `schemaVersion` getter
14 : // and a constructor telling drift where the database should be stored.
15 : // These are described in the getting started guide: https://drift.simonbinder.eu/setup/
16 7 : AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
17 :
18 3 : @override
19 : int get schemaVersion => 2;
20 :
21 1 : static QueryExecutor _openConnection() {
22 1 : return NativeDatabase.createInBackground(
23 3 : File(path.join(dbDirectory, 'network_tools_v1')),
24 : );
25 : }
26 : }
|