diff --git a/build.sbt b/build.sbt index d5dc5ff..af17e25 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val flywayAwsLambda = (project in file(".")).settings( organization := "crossroad0201.aws", name := "flyway-awslambda", - version := "0.1.0", + version := "0.2.0-SNAPSHOT", scalaVersion := "2.12.0", assemblyJarName := s"${name.value}-${version.value}.jar", diff --git a/src/main/scala/crossroad0201/aws/flywaylambda/S3EventMigrationHandler.scala b/src/main/scala/crossroad0201/aws/flywaylambda/S3EventMigrationHandler.scala index b4cba53..4ee3d20 100644 --- a/src/main/scala/crossroad0201/aws/flywaylambda/S3EventMigrationHandler.scala +++ b/src/main/scala/crossroad0201/aws/flywaylambda/S3EventMigrationHandler.scala @@ -98,9 +98,13 @@ class S3EventMigrationHandler extends RequestHandler[S3Event, String] { val objectKey = s3.getObject.getKey objectKey.substring(0, objectKey.lastIndexOf("/")) } - val objects = s3Client.listObjects(bucket.getName, migrationPrefix) - - deployInternal(objects.getObjectSummaries.asScala.toList, (None, ListBuffer())) match { + val objectSummaries = { + val objects = s3Client.listObjects(bucket.getName, migrationPrefix) + objects.getObjectSummaries.asScala.toList.sortWith { (x, y) => + x.getKey.compareTo(y.getKey) < 1 + } + } + deployInternal(objectSummaries, (None, ListBuffer())) match { case (Some(conf), sqlFiles) => FlywayDeployment( bucket.getName,