Skip to content

Commit

Permalink
Merge pull request #7 from RBusarow/preserve_indices_when_recreating_…
Browse files Browse the repository at this point in the history
…table

preserve indices when recreating a table
  • Loading branch information
RBusarow authored Aug 6, 2020
2 parents e08a0f9 + 579a761 commit 061f8b3
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,22 @@ class Migration(
sb.append(" FROM `").append(table1!!.name).append("`")

execSql(sb.toString())
tableDiff.indicesDiff.same.forEach {
createTableIndex(table2, it)
}
tableDiff.indicesDiff.added.forEach {
createTableIndex(table2, it)
}
dropTable(table1.name)
renameTable(tableMerge.name, table2.name)
}
} else {

tableDiff.indicesDiff.removed.forEach {
dropTableIndex(it)
}
tableDiff.indicesDiff.added.forEach {
createTableIndex(table2, it)
tableDiff.indicesDiff.removed.forEach {
dropTableIndex(it)
}
tableDiff.indicesDiff.added.forEach {
createTableIndex(table2, it)
}
}
}

Expand All @@ -148,7 +155,7 @@ class Migration(
val old = viewDiff.old
val new = viewDiff.new

old?.name?.let { dropView(it)}
old?.name?.let { dropView(it) }
createView(new)
}

Expand Down

0 comments on commit 061f8b3

Please sign in to comment.