parent
7671d68592
commit
13cc4195c8
@ -79,16 +79,27 @@ customMigrations :: MonadIO m => Map (Key AppliedMigration) (ReaderT SqlBackend
|
|||||||
customMigrations = Map.fromListWith (>>)
|
customMigrations = Map.fromListWith (>>)
|
||||||
[ ( AppliedMigrationKey [migrationVersion|initial|] [version|0.0.0|]
|
[ ( AppliedMigrationKey [migrationVersion|initial|] [version|0.0.0|]
|
||||||
, do -- New theme format
|
, do -- New theme format
|
||||||
userThemes <- [sqlQQ| SELECT @{UserId}, @{UserTheme} FROM ^{User}; |]
|
haveUserTable <- [sqlQQ| SELECT to_regclass('user'); |]
|
||||||
forM_ userThemes $ \(uid, Single str) -> case stripPrefix "theme--" str of
|
|
||||||
Just v
|
case haveUserTable :: [Maybe (Single Text)] of
|
||||||
| Just theme <- fromPathPiece v -> update uid [UserTheme =. theme]
|
[Just _] -> do
|
||||||
other -> error $ "Could not parse theme: " <> show other
|
userThemes <- [sqlQQ| SELECT 'id', 'theme' FROM 'user'; |]
|
||||||
|
forM_ userThemes $ \(uid, Single str) -> case stripPrefix "theme--" str of
|
||||||
|
Just v
|
||||||
|
| Just theme <- fromPathPiece v -> update uid [UserTheme =. theme]
|
||||||
|
other -> error $ "Could not parse theme: " <> show other
|
||||||
|
_other -> return ()
|
||||||
)
|
)
|
||||||
, ( AppliedMigrationKey [migrationVersion|0.0.0|] [version|1.0.0|]
|
, ( AppliedMigrationKey [migrationVersion|0.0.0|] [version|1.0.0|]
|
||||||
, [executeQQ| -- Better JSON encoding
|
, do -- Better JSON encoding
|
||||||
ALTER TABLE "sheet" ALTER COLUMN "type" TYPE json USING "type"::json;
|
haveSheetTable <- [sqlQQ| SELECT to_regclass('sheet'); |]
|
||||||
ALTER TABLE "sheet" ALTER COLUMN "grouping" TYPE json USING "grouping"::json;
|
|
||||||
|]
|
case haveSheetTable :: [Maybe (Single Text)] of
|
||||||
|
[Just _] ->
|
||||||
|
[executeQQ|
|
||||||
|
ALTER TABLE 'sheet' ALTER COLUMN 'type' TYPE json USING 'type'::json;
|
||||||
|
ALTER TABLE 'sheet' ALTER COLUMN 'grouping' TYPE json USING 'grouping'::json;
|
||||||
|
|]
|
||||||
|
_other -> return ()
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user