From 11756169c79e5f0a38c2f1540badee48113fc2bc Mon Sep 17 00:00:00 2001 From: Rick Busarow Date: Thu, 6 Aug 2020 16:07:31 -0500 Subject: [PATCH] enable legacy_alter_table for table renames in API 30+ --- .../main/java/dev/matrix/roomigrant/compiler/Migration.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/Migration.kt b/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/Migration.kt index 5d4e29e..06ce0b7 100644 --- a/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/Migration.kt +++ b/RoomigrantCompiler/src/main/java/dev/matrix/roomigrant/compiler/Migration.kt @@ -67,6 +67,12 @@ class Migration( createTableIndices(tableDiff.new) } + val pendingTableRename = diff.changedTables.any { it.fieldsDiff.wasChanged || it.nameChanged } + + if (pendingTableRename) { + execSql("PRAGMA legacy_alter_table=ON;") + } + for (tableDiff in diff.changedTables) { val table1 = tableDiff.old val table2 = tableDiff.new