Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
Merge pull request #56 from Ignas/master
Browse files Browse the repository at this point in the history
Do not do any queries if there were no migrations before.
  • Loading branch information
hhandoko authored Mar 29, 2018
2 parents 999b8b1 + 0aa24b5 commit b42778d
Showing 1 changed file with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,26 +309,18 @@ open class SchemaVersionDAO(private val session: Session, val keyspaceConfig: Ke
)
}

Collections.sort(migrationVersions)
if (migrationVersions.size == 0) {
return 1;
}

val batchStatement = BatchStatement()
Collections.sort(migrationVersions)

// TODO: Refactor for loop with idiomatic Kotlin collection methods
for (i in migrationVersions.indices) {
if (version.compareTo(migrationVersions[i]) < 0) {
for (z in i..migrationVersions.size - 1) {
val migrationVersionStr = migrationVersions[z].version
batchStatement.add(
boundUpdateVersionRankStmt(
migrationMetaHolders[migrationVersionStr]!!.versionRank + 1,
migrationVersionStr
)
)
}
return i + 1
}
}
session.execute(batchStatement)

return migrationVersions.size + 1
}
Expand Down

0 comments on commit b42778d

Please sign in to comment.