Files
dailyou/lib/core/database/tables.dart
T
stefwill 6f3fb74e7e feat: implement multi-step mood logging wizard
Adds sleep/energy/positivity/self-worth tracking columns to the database
(schema v2 migration), a new 5-option StepScale widget, per-answer chips
at the top of the screen, a 2×2 activity grid chip, and a full step-by-step
wizard flow: mood → sleep (first entry today only) → energy → positivity →
self-worth → activities → review+save.
2026-04-26 12:14:45 +10:00

77 lines
3.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:drift/drift.dart';
// ─── Mood Entries ────────────────────────────────────────────────────────────
class MoodEntries extends Table {
IntColumn get id => integer().autoIncrement()();
DateTimeColumn get timestamp => dateTime()();
IntColumn get moodLevel => integer()(); // 15
TextColumn get note => text().nullable()();
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
IntColumn get sleepMinutes => integer().nullable()();
IntColumn get energyLevel => integer().nullable()();
IntColumn get positivityLevel => integer().nullable()();
IntColumn get selfWorthLevel => integer().nullable()();
}
// ─── Activities ──────────────────────────────────────────────────────────────
class Activities extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text().withLength(min: 1, max: 50)();
IntColumn get iconCodepoint => integer()(); // Icons codepoint value
TextColumn get colourHex =>
text().withLength(min: 7, max: 7)(); // e.g. #FF5733
BoolColumn get isCustom => boolean().withDefault(const Constant(false))();
IntColumn get sortOrder => integer().withDefault(const Constant(0))();
}
// ─── Entry ↔ Activity (many-to-many) ─────────────────────────────────────────
class EntryActivities extends Table {
IntColumn get entryId => integer().references(MoodEntries, #id)();
IntColumn get activityId => integer().references(Activities, #id)();
@override
Set<Column> get primaryKey => {entryId, activityId};
}
// ─── Tags ────────────────────────────────────────────────────────────────────
class Tags extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get name => text().withLength(min: 1, max: 30)();
TextColumn get colourHex => text().withLength(min: 7, max: 7)();
}
// ─── Entry ↔ Tag (many-to-many) ───────────────────────────────────────────────
class EntryTags extends Table {
IntColumn get entryId => integer().references(MoodEntries, #id)();
IntColumn get tagId => integer().references(Tags, #id)();
@override
Set<Column> get primaryKey => {entryId, tagId};
}
// ─── LLM Insight Cache ───────────────────────────────────────────────────────
class LlmInsights extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get type => text()(); // 'weekly' | 'monthly' | 'query'
TextColumn get promptHash => text()(); // SHA256 of the prompt — cache key
TextColumn get responseText => text()();
DateTimeColumn get generatedAt =>
dateTime().withDefault(currentDateAndTime)();
DateTimeColumn get rangeStart => dateTime().nullable()();
DateTimeColumn get rangeEnd => dateTime().nullable()();
}
// ─── Settings ────────────────────────────────────────────────────────────────
class UserSettings extends Table {
IntColumn get id => integer().autoIncrement()();
TextColumn get key => text().withLength(min: 1, max: 50).unique()();
TextColumn get value => text()();
}