🛠️ Migration (booksDir deletion)
* Delete booksDir(if exists), which does not serve any purpose Part-of: #134
This commit is contained in:
parent
67a5f12b6a
commit
2114d7e6cd
2 changed files with 21 additions and 1 deletions
|
|
@ -62,6 +62,9 @@ object AppModule {
|
|||
@Provides
|
||||
@Singleton
|
||||
fun provideBookDao(app: Application): BookDao {
|
||||
// Additional Migrations
|
||||
DatabaseHelper.MIGRATION_7_8.removeBooksDir(app)
|
||||
|
||||
return Room.databaseBuilder(
|
||||
app,
|
||||
BookDatabase::class.java,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package ua.acclorite.book_story.data.local.room
|
||||
|
||||
import android.app.Application
|
||||
import androidx.room.AutoMigration
|
||||
import androidx.room.Database
|
||||
import androidx.room.DeleteColumn
|
||||
|
|
@ -12,6 +13,7 @@ import ua.acclorite.book_story.data.local.dto.BookEntity
|
|||
import ua.acclorite.book_story.data.local.dto.ColorPresetEntity
|
||||
import ua.acclorite.book_story.data.local.dto.FavoriteDirectoryEntity
|
||||
import ua.acclorite.book_story.data.local.dto.HistoryEntity
|
||||
import java.io.File
|
||||
|
||||
@Database(
|
||||
entities = [
|
||||
|
|
@ -87,5 +89,20 @@ object DatabaseHelper {
|
|||
|
||||
@DeleteColumn("BookEntity", "textPath")
|
||||
@DeleteColumn("BookEntity", "chapters")
|
||||
class MIGRATION_7_8 : AutoMigrationSpec
|
||||
class MIGRATION_7_8 : AutoMigrationSpec {
|
||||
companion object {
|
||||
/**
|
||||
* Along with textPath deletion,
|
||||
* books directory with text does not
|
||||
* serve any purpose.
|
||||
*/
|
||||
fun removeBooksDir(application: Application) {
|
||||
val booksDir = File(application.filesDir, "books")
|
||||
|
||||
if (booksDir.exists()) {
|
||||
booksDir.deleteRecursively()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue