-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Migrate from objectbox to drift.
I hate riverpod.
- Loading branch information
Showing
49 changed files
with
1,051 additions
and
1,384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
exclude: | ||
- "LICENSE" | ||
# Generated files. | ||
- "linux/**/*.cc" | ||
- "linux/**/*.h" | ||
- "windows/**/*.cc" | ||
- "windows/**/*.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:drift/drift.dart'; | ||
import 'package:tokhub/models/check_status.dart'; | ||
import 'package:tokhub/models/github.dart'; | ||
import 'package:tokhub/models/json_enum.dart'; | ||
|
||
part 'database.g.dart'; | ||
|
||
@DriftDatabase(tables: [ | ||
MinimalCheckRun, | ||
MinimalCommitStatus, | ||
MinimalPullRequest, | ||
MinimalRepository, | ||
MinimalUser, | ||
]) | ||
final class Database extends _$Database { | ||
Database(super.e); | ||
|
||
@override | ||
int get schemaVersion => 1; | ||
|
||
Future<void> clear() async { | ||
await transaction(() async { | ||
await delete(minimalCheckRun).go(); | ||
await delete(minimalCommitStatus).go(); | ||
await delete(minimalPullRequest).go(); | ||
await delete(minimalRepository).go(); | ||
await delete(minimalUser).go(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:tokhub/db/database.dart'; | ||
import 'package:drift/native.dart'; | ||
import 'package:path/path.dart' as path; | ||
import 'package:path_provider/path_provider.dart'; | ||
|
||
Future<Database> constructDb() async { | ||
final dbFolder = await getApplicationDocumentsDirectory(); | ||
final file = File(path.join(dbFolder.path, 'TokHub', 'db.sqlite')); | ||
return Database(NativeDatabase(file)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export 'unsupported.dart' | ||
if (dart.library.html) 'web.dart' | ||
if (dart.library.ffi) 'native.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import 'package:tokhub/db/database.dart'; | ||
|
||
Future<Database> constructDb() => throw UnimplementedError(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import 'package:tokhub/db/database.dart'; | ||
import 'package:drift/wasm.dart'; | ||
|
||
Future<Database> constructDb() async { | ||
final db = await WasmDatabase.open( | ||
databaseName: 'db', | ||
sqlite3Uri: Uri(path: 'sqlite3.wasm'), | ||
driftWorkerUri: Uri(path: 'drift_worker.js'), | ||
); | ||
return Database(db.resolvedExecutor); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.