Add associations
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -14,7 +15,16 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30301
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraArtifact::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["artifactId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraArtifactVersion(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -15,7 +16,16 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30302
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraArtifactVersion::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["artifactVersionId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraChapter(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -14,7 +15,16 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30303
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraChapter::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["chapterId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraChunk(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -15,7 +16,22 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30305
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraTranslationChunk::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["translationChunkId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
ForeignKey(
|
||||
entity = MantraTranslationArtifactVersion::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["translationArtifactVersionId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraTranslation(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -16,7 +17,16 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30306
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraArtifactVersion::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["artifactVersionId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraTranslationArtifactVersion(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -16,7 +17,16 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30307
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraTranslationArtifactVersionContributor::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["translationArtifactVersionId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraTranslationArtifactVersionContributor(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
import press.mantra.compose.database.model.traits.OptionalNostrEventEntity
|
||||
@@ -14,7 +15,16 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30308
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraTranslationArtifactVersion::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["translationArtifactVersionId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraTranslationChapter(
|
||||
val id: HexKey,
|
||||
val publicKey: HexKey,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -17,7 +18,16 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30310
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraTranslationChapter::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["translationChapterId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraTranslationChapterContributor(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
@@ -43,7 +53,7 @@ data class MantraTranslationChapterContributor(
|
||||
): OptionalNostrEventEntity, TimestampedEntity {
|
||||
|
||||
companion object {
|
||||
fun toTranslationChapterTranslatorListEvent(mantraTranslationChapterTranslators: List<MantraTranslationChapterTranslator>): TranslationChapterContributorListEvent {
|
||||
fun toTranslationChapterTranslatorListEvent(mantraTranslationChapterTranslators: List<MantraTranslationChapterContributor>): TranslationChapterContributorListEvent {
|
||||
// TODO: create TranslationChapterProofReaderListEvent from mantraTranslationChapterProofReaders
|
||||
return TranslationChapterContributorListEvent(
|
||||
id = "",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.TagArrayBuilder
|
||||
@@ -15,7 +16,22 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30311
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraChunk::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["chunkId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
ForeignKey(
|
||||
entity = MantraTranslationChapter::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["translationChapterId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraTranslationChunk(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package press.mantra.compose.database.model
|
||||
|
||||
import androidx.room3.Entity
|
||||
import androidx.room3.ForeignKey
|
||||
import androidx.room3.PrimaryKey
|
||||
import com.vitorpamplona.quartz.nip01Core.core.HexKey
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.EventHasher
|
||||
@@ -17,7 +18,16 @@ import kotlin.time.Instant
|
||||
/**
|
||||
* 30312
|
||||
*/
|
||||
@Entity
|
||||
@Entity(
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = MantraTranslation::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["translationId"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
)
|
||||
data class MantraTranslationContributor(
|
||||
@PrimaryKey
|
||||
val id: HexKey,
|
||||
|
||||
Reference in New Issue
Block a user