renameFrom in AlterTableMigration is giving an SQLiteException
See original GitHub issueDBFlow Version: 4.1.2
Bug or Feature Request: renameFrom is causing exception in basic application.
Link for code before migration: Before Migration Link for code after migration: After Migration
Description:
Following error received when running renameFrom:
android.database.sqlite.SQLiteException: there is already another table or index with this name: DiaryLogEntry (code 1): , while compiling: ALTER TABLE 'LogEntry' RENAME TO 'DiaryLogEntry'
Relevant code below or in the Github link provided Database Before Migration
@Database(name = MainDB.NAME, version = MainDB.VERSION)
object MainDB {
const val NAME = "MainDB"
const val VERSION = 1
}
Table Before Migration
@Table(database = MainDB::class, allFields = true)
class LogEntry {
@PrimaryKey
lateinit var entryId: String
lateinit var entryTitle: String
}
Database After Migration
@Database(name = MainDB.NAME, version = MainDB.VERSION)
object MainDB {
const val NAME = "MainDB"
const val VERSION = 2
}
@Migration(version = MainDB.VERSION, database = MainDB::class)
internal class MainDBMigration1 : AlterTableMigration<DiaryLogEntry>((DiaryLogEntry::class.java)) {
init {
renameFrom("LogEntry")
Timber.d("New name given to LogEntry. It is now DiaryLogEntry.")
}
}
Table After Migration
@Table(database = MainDB::class, name = "DiaryLogEntry", allFields = true)
class DiaryLogEntry {
@PrimaryKey
lateinit var entryId: String
lateinit var entryTitle: String
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Room Database Migration doesnt properly handle ALTER ...
The error message is hard to parse, but there's a difference: TableInfo{name='user', columns={name=Column{name='name', type='TEXT', ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, for your tip. I will try that.
I am using version 4.2.4(because I failed to include 5.0.1alpha),and I got the same problem. I think this is a issue which need to be fixed. now, we can do like this: