Files
dailyou/lib/core/database/tables.dart
T
stefwill 33d1713f51 feat: set up Flutter project with drift database, Riverpod providers, and LLM service layer
- Configure dependencies: drift 2.32.x, flutter_riverpod 3.3.1, fl_chart 1.2.x,
  flutter_local_notifications 21.x, local_auth 3.x, and supporting packages
- Drop riverpod_generator (incompatible analyzer version with drift_dev 2.32.x);
  convert all providers to manual Riverpod 3.x API using Notifier<T> and typed families
- Define drift schema: MoodEntries, Activities, EntryActivities, Tags, EntryTags,
  LlmInsights, UserSettings with four DAOs (mood, activity, insight, settings)
- Add LLM service abstraction (LlmService) and MediaPipe implementation
- Fix SettingsDao.delete → deleteByKey to avoid shadowing drift's inherited delete method
2026-04-26 10:39:51 +10:00

73 lines
3.5 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)();
}
// ─── 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()();
}