Skip to content

Commit

Permalink
fixed findAllMigrations still trying to access Application/Migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Nov 19, 2024
1 parent f59b36f commit 7a4c95f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions IHP/SchemaMigration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ findMigratedRevisions = map (\[revision] -> revision) <$> sqlQuery "SELECT revis
-- The result is sorted so that the oldest revision is first.
findAllMigrations :: IO [Migration]
findAllMigrations = do
directoryFiles <- Directory.listDirectory "Application/Migration"
migrationDir <- detectMigrationDir
directoryFiles <- Directory.listDirectory (cs migrationDir)
directoryFiles
|> map cs
|> filter (\path -> ".sql" `isSuffixOf` path)
Expand Down Expand Up @@ -128,5 +129,10 @@ pathToMigration fileName = case revision of

migrationPath :: Migration -> IO Text
migrationPath Migration { migrationFile } = do
migrationDir <- envOrDefault "IHP_MIGRATION_DIR" "Application/Migration/"
migrationDir <- detectMigrationDir
pure (migrationDir <> migrationFile)

detectMigrationDir :: IO Text
detectMigrationDir =
envOrDefault "IHP_MIGRATION_DIR" "Application/Migration/"

0 comments on commit 7a4c95f

Please sign in to comment.