Migrate database (2)
This commit is contained in:
@@ -1,12 +0,0 @@
|
||||
package it.vfsfitvnm.vimusic.models
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
// I know...
|
||||
@Entity
|
||||
data class Info(
|
||||
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||
val browseId: String?,
|
||||
val text: String
|
||||
)
|
||||
@@ -15,7 +15,7 @@ data class PlaylistWithSongs(
|
||||
entityColumn = "songId"
|
||||
)
|
||||
)
|
||||
val songs: List<SongWithInfo>
|
||||
val songs: List<DetailedSong>
|
||||
) {
|
||||
companion object {
|
||||
val Empty = PlaylistWithSongs(Playlist(-1, ""), emptyList())
|
||||
|
||||
@@ -3,7 +3,16 @@ package it.vfsfitvnm.vimusic.models
|
||||
import androidx.room.*
|
||||
|
||||
|
||||
@Entity
|
||||
@Entity(
|
||||
// foreignKeys = [
|
||||
// ForeignKey(
|
||||
// entity = Album::class,
|
||||
// parentColumns = ["id"],
|
||||
// childColumns = ["albumId"],
|
||||
// onDelete = ForeignKey.CASCADE
|
||||
// ),
|
||||
// ]
|
||||
)
|
||||
data class Song(
|
||||
@PrimaryKey val id: String,
|
||||
val title: String,
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package it.vfsfitvnm.vimusic.models
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.room.*
|
||||
|
||||
|
||||
@Immutable
|
||||
@Entity(
|
||||
primaryKeys = ["songId", "authorInfoId"],
|
||||
foreignKeys = [
|
||||
ForeignKey(
|
||||
entity = Song::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["songId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
),
|
||||
ForeignKey(
|
||||
entity = Info::class,
|
||||
parentColumns = ["id"],
|
||||
childColumns = ["authorInfoId"],
|
||||
onDelete = ForeignKey.CASCADE
|
||||
)
|
||||
]
|
||||
)
|
||||
data class SongWithAuthors(
|
||||
val songId: String,
|
||||
@ColumnInfo(index = true) val authorInfoId: Long
|
||||
)
|
||||
@@ -1,25 +0,0 @@
|
||||
package it.vfsfitvnm.vimusic.models
|
||||
|
||||
import androidx.room.Embedded
|
||||
import androidx.room.Junction
|
||||
import androidx.room.Relation
|
||||
|
||||
open class SongWithInfo(
|
||||
@Embedded val song: Song,
|
||||
@Relation(
|
||||
entity = Info::class,
|
||||
parentColumn = "albumId",
|
||||
entityColumn = "id"
|
||||
) val album: Info?,
|
||||
@Relation(
|
||||
entity = Info::class,
|
||||
parentColumn = "id",
|
||||
entityColumn = "id",
|
||||
associateBy = Junction(
|
||||
value = SongWithAuthors::class,
|
||||
parentColumn = "songId",
|
||||
entityColumn = "authorInfoId"
|
||||
)
|
||||
)
|
||||
val authors: List<Info>?
|
||||
)
|
||||
Reference in New Issue
Block a user