fix(build): prevent migration on non-existing table
This commit is contained in:
parent
21ab898607
commit
5bb49cd889
@ -885,7 +885,7 @@ customMigrations = mapF $ \case
|
|||||||
|]
|
|]
|
||||||
|
|
||||||
Migration20230703LmsUserStatus ->
|
Migration20230703LmsUserStatus ->
|
||||||
unlessM (columnExists "lms_user" "status_day") $ do
|
whenM (columnNotExists "lms_user" "status_day") $ do
|
||||||
[executeQQ|
|
[executeQQ|
|
||||||
ALTER TABLE "lms_user" ADD COLUMN "status_day" date;
|
ALTER TABLE "lms_user" ADD COLUMN "status_day" date;
|
||||||
UPDATE "lms_user"
|
UPDATE "lms_user"
|
||||||
@ -928,3 +928,10 @@ columnExists table column = do
|
|||||||
case haveColumn :: [Single PersistValue] of
|
case haveColumn :: [Single PersistValue] of
|
||||||
[_] -> return True
|
[_] -> return True
|
||||||
_other -> return False
|
_other -> return False
|
||||||
|
|
||||||
|
-- | equivalent to andM [ tableExists, not <$> columnExists]
|
||||||
|
columnNotExists :: MonadIO m
|
||||||
|
=> Text -- ^ Table
|
||||||
|
-> Text -- ^ Column
|
||||||
|
-> ReaderT SqlBackend m Bool
|
||||||
|
columnNotExists table column = and2M (tableExists table) (not <$> columnExists table column)
|
||||||
|
|||||||
Reference in New Issue
Block a user