Skip to content

Commit 41ec105

Browse files
fix(persistence): make optional fields nullable in task and habit tables
Update database schema to explicitly allow NULL values for optional fields in task_table_new (e.g., description, priority, dates, recurrence params) and habit_record_table_new (e.g., occurred_at, modified_date). Add CHECK constraint to is_completed for boolean validation. Regenerate main.mapper.g.dart due to model reflection updates.
1 parent 9227124 commit 41ec105

File tree

2 files changed

+694
-694
lines changed

2 files changed

+694
-694
lines changed

src/lib/infrastructure/persistence/shared/contexts/drift/drift_app_context.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -441,27 +441,27 @@ class AppDatabase extends _$AppDatabase {
441441
await customStatement('''
442442
CREATE TABLE task_table_new (
443443
id TEXT NOT NULL,
444-
parent_task_id TEXT,
444+
parent_task_id TEXT NULL,
445445
title TEXT NOT NULL,
446-
description TEXT,
447-
priority INTEGER,
448-
planned_date INTEGER,
449-
deadline_date INTEGER,
450-
estimated_time INTEGER,
451-
is_completed INTEGER NOT NULL DEFAULT 0,
446+
description TEXT NULL,
447+
priority INTEGER NULL,
448+
planned_date INTEGER NULL,
449+
deadline_date INTEGER NULL,
450+
estimated_time INTEGER NULL,
451+
is_completed INTEGER NOT NULL DEFAULT (0) CHECK ("is_completed" IN (0, 1)),
452452
created_date INTEGER NOT NULL,
453-
modified_date INTEGER,
454-
deleted_date INTEGER,
453+
modified_date INTEGER NULL,
454+
deleted_date INTEGER NULL,
455455
"order" REAL NOT NULL DEFAULT 0.0,
456456
planned_date_reminder_time INTEGER NOT NULL DEFAULT 0,
457457
deadline_date_reminder_time INTEGER NOT NULL DEFAULT 0,
458458
recurrence_type INTEGER NOT NULL DEFAULT 0,
459-
recurrence_interval INTEGER,
460-
recurrence_days_string TEXT,
461-
recurrence_start_date INTEGER,
462-
recurrence_end_date INTEGER,
463-
recurrence_count INTEGER,
464-
recurrence_parent_id TEXT,
459+
recurrence_interval INTEGER NULL,
460+
recurrence_days_string TEXT NULL,
461+
recurrence_start_date INTEGER NULL,
462+
recurrence_end_date INTEGER NULL,
463+
recurrence_count INTEGER NULL,
464+
recurrence_parent_id TEXT NULL,
465465
PRIMARY KEY (id)
466466
)
467467
''');
@@ -482,10 +482,10 @@ class AppDatabase extends _$AppDatabase {
482482
CREATE TABLE habit_record_table_new (
483483
id TEXT NOT NULL,
484484
created_date INTEGER NOT NULL,
485-
modified_date INTEGER,
486-
deleted_date INTEGER,
485+
modified_date INTEGER NULL,
486+
deleted_date INTEGER NULL,
487487
habit_id TEXT NOT NULL,
488-
occurred_at INTEGER NOT NULL,
488+
occurred_at INTEGER NULL,
489489
PRIMARY KEY (id)
490490
)
491491
''');

0 commit comments

Comments
 (0)