From b35c8cca57811050536a4fa6c1cb5675453ad463 Mon Sep 17 00:00:00 2001 From: Mikkel Thestrup Date: Tue, 27 Jan 2026 17:07:13 +0100 Subject: feat(infrastructure): implement SQLite persistence layer for calendar domain Add infrastructure layer with SQLite repositories for calendars, events, and recurring events. Implements the repository pattern with proper domain/infrastructure separation. - Add CalendarModel, EventModel, RecurrenceModel, and RecurrenceExceptionModel for database persistence - Implement SqliteCalendarRepository with CRUD operations - Implement SqliteEventRepository with calendar filtering and time range queries - Implement SqliteRecurringEventRepository with exception handling and transactions - Add bidirectional mappers between domain entities and persistence models - Use sqlx query_as for type-safe database queries with FromRow derivation - Support upsert operations for all entities using ON CONFLICT clauses --- src/infrastructure/persistence/models.rs | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/infrastructure/persistence/models.rs (limited to 'src/infrastructure/persistence/models.rs') diff --git a/src/infrastructure/persistence/models.rs b/src/infrastructure/persistence/models.rs new file mode 100644 index 0000000..dc39e94 --- /dev/null +++ b/src/infrastructure/persistence/models.rs @@ -0,0 +1,53 @@ +use sqlx::FromRow; + +#[derive(Debug, FromRow)] +pub struct CalendarModel { + pub id: String, + pub name: String, + pub description: Option, + pub is_archived: i64, + pub created_at: String, + pub updated_at: String, +} + +#[derive(Debug, FromRow)] +pub struct EventModel { + pub id: String, + pub calendar_id: String, + pub title: String, + pub description: Option, + pub starts_at: String, + pub ends_at: String, + pub color: i64, + pub is_all_day: i64, + pub is_cancelled: i64, + pub created_at: String, + pub updated_at: String, +} + +#[derive(Debug, FromRow)] +pub struct RecurrenceModel { + pub id: String, + pub calendar_id: String, + pub title: String, + pub description: Option, + pub starts_at: String, + pub ends_at: String, + pub frequency: String, + pub interval: i64, + pub until: Option, + pub color: i64, + pub is_all_day: i64, + pub is_cancelled: i64, + pub created_at: String, + pub updated_at: String, +} + +#[derive(Debug, FromRow)] +pub struct RecurrenceExceptionModel { + pub recurrence_id: String, + pub original_starts_at: String, + pub new_starts_at: Option, + pub new_ends_at: Option, + pub is_cancelled: i64, +} -- cgit v1.2.3-70-g09d2