Skip to content

Commit

Permalink
Add to many tags entities
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikstonge committed Dec 30, 2024
1 parent 65201c5 commit 18f1142
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 783 deletions.
16 changes: 14 additions & 2 deletions lib/repositories/database_repository.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import 'package:drift/drift.dart';
import 'package:drift_flutter/drift_flutter.dart';

import '../services/toaster_service.dart';
import 'entities/match_entity.dart';
import 'entities/pacing_entity.dart';
import 'entities/team_entity.dart';
import 'legacy_database_repository.dart';

part 'database_repository.g.dart';

@DriftDatabase(tables: [PacingEntity, MatchEntity, TeamEntity])
class AppDatabase extends _$AppDatabase {
AppDatabase() : super(_openConnection());
final LegacyDatabaseRepository legacyDatabaseRepository;
final ToasterService toasterService;

AppDatabase({
required this.legacyDatabaseRepository,
required this.toasterService,
}) : super(_openConnection());

@override
int get schemaVersion => 1;
Expand All @@ -18,10 +26,14 @@ class AppDatabase extends _$AppDatabase {
MigrationStrategy get migration => MigrationStrategy(
beforeOpen: (details) async {
await customStatement('PRAGMA foreign_keys = ON');

if (details.wasCreated) {
// Migrate data from the legacy database
}
},
);

static QueryExecutor _openConnection() {
return driftDatabase(name: 'my_database');
return driftDatabase(name: 'mon_pacing_drift');
}
}
Loading

0 comments on commit 18f1142

Please sign in to comment.