Add foreign key constraint to Song

This commit is contained in:
vfsfitvnm
2022-06-29 15:26:01 +02:00
parent 95879e7a6e
commit 9103c30044
3 changed files with 441 additions and 9 deletions

View File

@@ -150,7 +150,7 @@ interface Database {
views = [
SortedSongInPlaylist::class
],
version = 9,
version = 10,
exportSchema = true,
autoMigrations = [
AutoMigration(from = 1, to = 2),
@@ -160,6 +160,7 @@ interface Database {
AutoMigration(from = 5, to = 6),
AutoMigration(from = 6, to = 7),
AutoMigration(from = 7, to = 8, spec = DatabaseInitializer.From7To8Migration::class),
AutoMigration(from = 9, to = 10),
],
)
@TypeConverters(Converters::class)

View File

@@ -4,14 +4,14 @@ import androidx.room.*
@Entity(
// foreignKeys = [
// ForeignKey(
// entity = Album::class,
// parentColumns = ["id"],
// childColumns = ["albumId"],
// onDelete = ForeignKey.CASCADE
// ),
// ]
foreignKeys = [
ForeignKey(
entity = Album::class,
parentColumns = ["id"],
childColumns = ["albumId"],
onDelete = ForeignKey.SET_NULL
),
]
)
data class Song(
@PrimaryKey val id: String,