@@ -248,22 +248,13 @@ class PgCodeGen private (
248248 _ <- Future {
249249 if debug then println(" Running migrations..." )
250250
251- val sortedFiles = sourceFiles
252- .map(p =>
253- MigrationVersion .fromFileName(p.getFileName().toString()) match
254- case Right (v) => p -> v
255- case Left (err) => throw Throwable (s " Invalid migration file name: $err" )
256- )
257- .sortBy((_, version) => version)
258- .map((path, _) => path)
259-
260251 Zone :
261252 Using (
262253 Database (connectionString).either match
263254 case Left (err) => throw err
264255 case Right (db) => db
265256 )(db =>
266- sortedFiles .foreach: path =>
257+ sourceFiles .foreach: path =>
267258 if debug then println(s " Running migration for $path" )
268259 db.execute(Files .readString(path)).either match
269260 case Left (err) => throw err
@@ -759,12 +750,19 @@ object PgCodeGen {
759750 def listMigrationFiles : Future [(List [Path ], String )] = Future :
760751 val digest = MessageDigest .getInstance(" SHA-1" )
761752 val files = listFilesRec(sourceDir.toPath)
762- .map(path =>
763- digest.update(path.toString.getBytes(" UTF-8" ))
764- if ! Files .isDirectory(path) then digest.update(Files .readAllBytes(path))
753+ .filter(! Files .isDirectory(_))
754+ .map(p =>
755+ MigrationVersion .fromFileName(p.getFileName().toString()) match
756+ case Right (v) => Some (p -> v)
757+ case Left (_) if ! p.endsWith(" .sql" ) => None // ignore non .sql files
758+ case Left (err) => throw Throwable (s " Invalid migration file name: $err" )
759+ )
760+ .collect { case Some (v) => v }
761+ .sortBy((_, version) => version)
762+ .map((path, _) =>
763+ digest.update(Files .readAllBytes(path))
765764 path
766765 )
767- .filter(! Files .isDirectory(_))
768766
769767 (files, digest.digest().map(" %02x" .format(_)).mkString)
770768
@@ -775,7 +773,13 @@ object PgCodeGen {
775773 else
776774 listMigrationFiles.flatMap:
777775 case (sourceFiles, sha1) =>
776+ if debug then println(s " Found ${sourceFiles.length} migration files (SHA1: $sha1) " )
777+
778778 val isDivergent = ! Files .exists(outDir(sha1))
779+
780+ if debug && isDivergent then
781+ println(s " No generated files found in: ${outDir(sha1).toAbsolutePath().toString()}" )
782+
779783 if forceRegeneration || isDivergent then
780784 for
781785 _ <-
0 commit comments