persistent 2.1.5 → 2.1.6
raw patch · 4 files changed
+27/−8 lines, 4 files
Files
- ChangeLog.md +8/−0
- Database/Persist/Quasi.hs +5/−2
- Database/Persist/Sql/Migration.hs +7/−4
- persistent.cabal +7/−2
ChangeLog.md view
@@ -1,3 +1,11 @@+## 2.1.6++Important! If persistent-template is not upgraded to 2.1.3.3+you might need to make sure `Int64` is in scope for your model declarations.++* add showMigration function+* explicitly use Int64 for foreign key references+ ## 2.1.5 Add `dbIdColumnsEsc` to Sql.Utils.
Database/Persist/Quasi.hs view
@@ -356,11 +356,14 @@ , fieldType = FTTypeCon Nothing $ keyConName $ unHaskellName entName , fieldSqlType = idSqlType -- the primary field is actually a reference to the entity- , fieldReference = ForeignRef entName (FTTypeCon Nothing "Int")+ , fieldReference = ForeignRef entName defaultReferenceTypeCon , fieldAttrs = [] , fieldStrict = True } +defaultReferenceTypeCon :: FieldType+defaultReferenceTypeCon = FTTypeCon (Just "Data.Int") "Int64"+ keyConName :: Text -> Text keyConName entName = entName `mappend` "Id" @@ -432,7 +435,7 @@ addDefaultIdType = takeColsEx ps (field : keyCon : rest `mappend` setIdName) setFieldDef = fmap (\fd -> let refFieldType = if fieldType fd == FTTypeCon Nothing keyCon- then FTTypeCon Nothing "Int"+ then defaultReferenceTypeCon else fieldType fd in fd { fieldReference = ForeignRef (HaskellName tableName) $ refFieldType })
Database/Persist/Sql/Migration.hs view
@@ -4,6 +4,7 @@ ( parseMigration , parseMigration' , printMigration+ , showMigration , getMigration , runMigration , runMigrationSilent@@ -52,11 +53,13 @@ Right sql -> return sql printMigration :: MonadIO m => Migration -> ReaderT SqlBackend m ()-printMigration m = do- mig <- parseMigration' m- mapM_ (liftIO . Data.Text.IO.putStrLn . flip snoc ';') (allSql mig)+printMigration m = showMigration m+ >>= mapM_ (liftIO . Data.Text.IO.putStrLn) -getMigration :: (MonadBaseControl IO m, MonadIO m) => Migration -> ReaderT SqlBackend m [Sql]+showMigration :: MonadIO m => Migration -> ReaderT SqlBackend m [Text]+showMigration m = map (flip snoc ';') `liftM` getMigration m++getMigration :: MonadIO m => Migration -> ReaderT SqlBackend m [Sql] getMigration m = do mig <- parseMigration' m return $ allSql mig
persistent.cabal view
@@ -1,5 +1,5 @@ name: persistent-version: 2.1.5+version: 2.1.6 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -50,7 +50,6 @@ , mtl , fast-logger >= 2.1 , scientific- , resource-pool , tagged exposed-modules: Database.Persist@@ -106,6 +105,12 @@ , monad-control , blaze-html , scientific+ , tagged+ , fast-logger >= 2.1+ , lifted-base >= 0.1+ , mtl+ , template-haskell+ , resource-pool cpp-options: -DTEST