From 64030832a998bedd6fa70c1ce6440073a537f073 Mon Sep 17 00:00:00 2001 From: tibbi Date: Fri, 23 Oct 2020 20:44:14 +0200 Subject: [PATCH] updating migration query once again --- .../musicplayer/activities/TrackActivity.kt | 1 - .../musicplayer/databases/SongsDatabase.kt | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt index b55c635f..8821446b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/TrackActivity.kt @@ -19,7 +19,6 @@ import com.bumptech.glide.request.RequestOptions import com.google.gson.Gson import com.google.gson.reflect.TypeToken import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.helpers.mydebug import com.simplemobiletools.musicplayer.R import com.simplemobiletools.musicplayer.extensions.config import com.simplemobiletools.musicplayer.extensions.sendIntent diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/databases/SongsDatabase.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/databases/SongsDatabase.kt index 23fb3774..32da34b9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/databases/SongsDatabase.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/databases/SongsDatabase.kt @@ -112,16 +112,15 @@ abstract class SongsDatabase : RoomDatabase() { } } - // change the primary keys from path + playlist_id to id + playlist_id + // change the primary keys from path + playlist_id to media_store_id + playlist_id private val MIGRATION_4_5 = object : Migration(4, 5) { override fun migrate(database: SupportSQLiteDatabase) { database.apply { execSQL("CREATE TABLE songs_new (media_store_id INTEGER NOT NULL, title TEXT NOT NULL, artist TEXT NOT NULL, path TEXT NOT NULL, duration INTEGER NOT NULL, " + - "album TEXT NOT NULL, playlist_id INTEGER NOT NULL, track_id INTEGER NOT NULL DEFAULT 0, " + - "cover_art TEXT default '' NOT NULL, PRIMARY KEY(media_store_id, playlist_id))") + "album TEXT NOT NULL, cover_art TEXT default '' NOT NULL, playlist_id INTEGER NOT NULL, track_id INTEGER NOT NULL DEFAULT 0, PRIMARY KEY(media_store_id, playlist_id))") - execSQL("INSERT OR IGNORE INTO songs_new (media_store_id, title, artist, path, duration, album, playlist_id) " + - "SELECT media_store_id, title, artist, path, duration, album, playlist_id FROM songs") + execSQL("INSERT OR IGNORE INTO songs_new (media_store_id, title, artist, path, duration, album, cover_art, playlist_id, track_id) " + + "SELECT media_store_id, title, artist, path, duration, album, cover_art, playlist_id, track_id FROM songs") execSQL("DROP TABLE songs") execSQL("ALTER TABLE songs_new RENAME TO tracks")