mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-26 10:35:04 +03:00
Add check if migrations dir exists before copying (#1562)
This commit is contained in:
parent
2752f889c8
commit
96ea796067
@ -19,6 +19,7 @@ app todoApp {
|
||||
|
||||
### 🐞 Bug fixes / 🔧 small improvements
|
||||
- Changed the minimum number of machines that a server app is using when deployed to Fly.io from 0 to 1. This prevents the server app from shutting down when there are no requests to it. There might be some other work that the server is doing e.g. running periodic Jobs or sending e-mails, so we want to make sure that the server is always running.
|
||||
- Fixes a bug where copying of migrations dir failed due to a missing `migrations` dir.
|
||||
|
||||
|
||||
## 0.11.7
|
||||
|
@ -36,7 +36,7 @@ import Wasp.Generator.DbGenerator.Common
|
||||
webAppPrismaClientOutputDirEnv,
|
||||
)
|
||||
import qualified Wasp.Generator.DbGenerator.Jobs as DbJobs
|
||||
import Wasp.Generator.FileDraft.WriteableMonad (WriteableMonad (copyDirectoryRecursive))
|
||||
import Wasp.Generator.FileDraft.WriteableMonad (WriteableMonad (copyDirectoryRecursive, doesDirectoryExist))
|
||||
import qualified Wasp.Generator.Job as J
|
||||
import Wasp.Generator.Job.IO (printJobMsgsUntilExitReceived, readJobMessagesAndPrintThemPrefixed)
|
||||
import qualified Wasp.Generator.WriteFileDrafts as Generator.WriteFileDrafts
|
||||
@ -62,7 +62,7 @@ finalizeMigration :: Path' Abs (Dir ProjectRootDir) -> Path' Abs (Dir DbMigratio
|
||||
finalizeMigration genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs onLastDbConcurrenceChecksumFileRefreshAction = do
|
||||
-- NOTE: We are updating a managed CopyDirFileDraft outside the normal generation process, so we must invalidate the checksum entry for it.
|
||||
Generator.WriteFileDrafts.removeFromChecksumFile genProjectRootDirAbs [Right $ SP.castDir dbMigrationsDirInProjectRootDir]
|
||||
res <- copyMigrationsBackToSource genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs
|
||||
res <- copyMigrationsBackToSourceIfTheyExist genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs
|
||||
applyOnLastDbConcurrenceChecksumFileRefreshAction
|
||||
return res
|
||||
where
|
||||
@ -76,12 +76,20 @@ finalizeMigration genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs onLast
|
||||
IgnoreOnLastDbConcurrenceChecksumFile -> return ()
|
||||
|
||||
-- | Copies the DB migrations from the generated project dir back up to theh wasp project dir
|
||||
copyMigrationsBackToSource :: Path' Abs (Dir ProjectRootDir) -> Path' Abs (Dir DbMigrationsDir) -> IO (Either String ())
|
||||
copyMigrationsBackToSource genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs =
|
||||
copyMigrationsBackToSourceIfTheyExist ::
|
||||
Path' Abs (Dir ProjectRootDir) ->
|
||||
Path' Abs (Dir DbMigrationsDir) ->
|
||||
IO (Either String ())
|
||||
copyMigrationsBackToSourceIfTheyExist genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs = do
|
||||
doesDirectoryExist (SP.fromAbsDir genProjectMigrationsDir) >>= \case
|
||||
False -> return $ Right ()
|
||||
True -> copyMigrationsDir
|
||||
where
|
||||
copyMigrationsDir =
|
||||
copyDirectoryRecursive genProjectMigrationsDir waspMigrationsDir >> return (Right ())
|
||||
`catch` (\e -> return $ Left $ show (e :: P.PathException))
|
||||
`catch` (\e -> return $ Left $ show (e :: IOError))
|
||||
where
|
||||
|
||||
waspMigrationsDir = dbMigrationsDirInWaspProjectDirAbs
|
||||
genProjectMigrationsDir = genProjectRootDirAbs </> dbRootDirInProjectRootDir </> dbMigrationsDirInDbRootDir
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user