-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add check if migrations dir exists before copying #1562
Conversation
Signed-off-by: Mihovil Ilakovac <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice @infomiho ! I approved, but also left one/two comments that possibly improve code a bit, take a look and do as you like with them.
copyMigrationsBackToSource genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs = do | ||
doesMigrationsDirExist <- doesDirectoryExist $ SP.fromAbsDir genProjectMigrationsDir | ||
|
||
if doesMigrationsDirExist | ||
then copyMigrationsDir | ||
else return $ Right () | ||
where | ||
copyMigrationsDir = | ||
copyDirectoryRecursive genProjectMigrationsDir waspMigrationsDir >> return (Right ()) | ||
`catch` (\e -> return $ Left $ show (e :: P.PathException)) | ||
`catch` (\e -> return $ Left $ show (e :: IOError)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyMigrationsBackToSource genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs = do | |
doesMigrationsDirExist <- doesDirectoryExist $ SP.fromAbsDir genProjectMigrationsDir | |
if doesMigrationsDirExist | |
then copyMigrationsDir | |
else return $ Right () | |
where | |
copyMigrationsDir = | |
copyDirectoryRecursive genProjectMigrationsDir waspMigrationsDir >> return (Right ()) | |
`catch` (\e -> return $ Left $ show (e :: P.PathException)) | |
`catch` (\e -> return $ Left $ show (e :: IOError)) | |
copyMigrationsBackToSource genProjectRootDirAbs dbMigrationsDirInWaspProjectDirAbs = do | |
doesDirectoryExist (SP.fromAbsDir genProjectMigrationsDir) >>= \case -> | |
False -> return $ Right () | |
True -> copyDirectoryRecursive genProjectMigrationsDir waspMigrationsDir >> return (Right ()) | |
`catch` (\e -> return $ Left $ show (e :: P.PathException)) | |
`catch` (\e -> return $ Left $ show (e :: IOError)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also consider renaming whole functoin to copyMigrationsBackToSourceIfTheyExist
, but I am not sure, we can also skip it maybe.
Closes #1352