feat(08-01): add isActive column, migration v3, softDeleteTask and getCompletionCount

- Add isActive BoolColumn (default true) to Tasks table
- Bump schema version from 2 to 3 with addColumn migration
- Filter watchTasksInRoom to isActive=true only
- Filter getOverdueTaskCount to isActive=true only
- Add softDeleteTask(taskId) - sets isActive=false without removing data
- Add getCompletionCount(taskId) - counts TaskCompletions for a task
This commit is contained in:
2026-03-18 20:49:45 +01:00
parent a2cef91d7e
commit 4b51f5fa04
3 changed files with 98 additions and 6 deletions

View File

@@ -35,6 +35,8 @@ class Tasks extends Table {
DateTimeColumn get nextDueDate => dateTime()();
DateTimeColumn get createdAt =>
dateTime().clientDefault(() => DateTime.now())();
BoolColumn get isActive =>
boolean().withDefault(const Constant(true))();
}
/// TaskCompletions table: records when a task was completed.
@@ -53,7 +55,7 @@ class AppDatabase extends _$AppDatabase {
: super(executor ?? _openConnection());
@override
int get schemaVersion => 2;
int get schemaVersion => 3;
@override
MigrationStrategy get migration {
@@ -67,6 +69,9 @@ class AppDatabase extends _$AppDatabase {
await m.createTable(tasks);
await m.createTable(taskCompletions);
}
if (from < 3) {
await m.addColumn(tasks, tasks.isActive);
}
},
beforeOpen: (details) async {
await customStatement('PRAGMA foreign_keys = ON');