From b00d7366d968e52783760e42519d044a0586fe0f Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 16 Nov 2018 11:45:33 +0100 Subject: [PATCH] set up foreign keys at event repetitions and repetition exceptions --- .../calendar/pro/models/EventRepetition.kt | 8 +++----- .../calendar/pro/models/EventRepetitionException.kt | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/EventRepetition.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/EventRepetition.kt index 86db25efb..0e94ba01d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/EventRepetition.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/EventRepetition.kt @@ -1,11 +1,9 @@ package com.simplemobiletools.calendar.pro.models -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.Index -import androidx.room.PrimaryKey +import androidx.room.* -@Entity(tableName = "event_repetitions", indices = [(Index(value = ["id"], unique = true))]) +@Entity(tableName = "event_repetitions", indices = [(Index(value = ["id"], unique = true))], + foreignKeys = [ForeignKey(entity = Event::class, onDelete = ForeignKey.CASCADE, parentColumns = ["id"], childColumns = ["event_id"])]) data class EventRepetition( @PrimaryKey(autoGenerate = true) var id: Long?, @ColumnInfo(name = "event_id") val eventId: Long, diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/EventRepetitionException.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/EventRepetitionException.kt index f6d993fdf..f27ce38fc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/EventRepetitionException.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/models/EventRepetitionException.kt @@ -1,11 +1,9 @@ package com.simplemobiletools.calendar.pro.models -import androidx.room.ColumnInfo -import androidx.room.Entity -import androidx.room.Index -import androidx.room.PrimaryKey +import androidx.room.* -@Entity(tableName = "event_repetition_exceptions", indices = [(Index(value = ["id"], unique = true))]) +@Entity(tableName = "event_repetition_exceptions", indices = [(Index(value = ["id"], unique = true))], + foreignKeys = [ForeignKey(entity = Event::class, onDelete = ForeignKey.CASCADE, parentColumns = ["id"], childColumns = ["event_id"])]) data class EventRepetitionException( @PrimaryKey(autoGenerate = true) var id: Long?, @ColumnInfo(name = "occurrence_daycode") val daycode: String,