packages feed

groundhog-mysql 0.4.2 → 0.4.2.2

raw patch · 3 files changed

+41/−11 lines, 3 filesdep ~groundhog

Dependency ranges changed: groundhog

Files

Database/Groundhog/MySQL.hs view
@@ -44,7 +44,7 @@ import Data.Int (Int64) import Data.IORef (newIORef, readIORef, writeIORef) import Data.List (groupBy, intercalate, intersect, partition, stripPrefix)-import Data.Maybe (fromJust, fromMaybe)+import Data.Maybe (fromJust, fromMaybe, isJust) import Data.Pool  newtype MySQL = MySQL MySQL.Connection@@ -93,6 +93,7 @@   getList k = getList' k  instance (MonadBaseControl IO m, MonadIO m, MonadLogger m) => SchemaAnalyzer (DbPersist MySQL m) where+  schemaExists schema = queryRaw' "SELECT 1 FROM information_schema.schemata WHERE schema_name=?" [toPrimitivePersistValue proxy schema] (fmap isJust)   listTables schema = queryRaw' "SELECT table_name FROM information_schema.tables WHERE table_schema=coalesce(?,database())" [toPrimitivePersistValue proxy schema] (mapAllRows $ return . fst . fromPurePersistValues proxy)   listTableTriggers schema name = queryRaw' "SELECT trigger_name FROM information_schema.triggers WHERE event_object_schema=coalesce(?,database()) AND event_object_table=?" [toPrimitivePersistValue proxy schema, toPrimitivePersistValue proxy name] (mapAllRows $ return . fst . fromPurePersistValues proxy)   analyzeTable = analyzeTable'@@ -271,7 +272,8 @@ migrate' v = do   x <- lift $ queryRaw' "SELECT database()" [] id   let schema = fst $ fromPurePersistValues proxy $ fromJust x-  migrateRecursively (migrateEntity $ migrationPack schema) (migrateList $ migrationPack schema) v+      migPack = migrationPack schema+  migrateRecursively (migrateSchema migPack) (migrateEntity migPack) (migrateList migPack) v  migrationPack :: (MonadBaseControl IO m, MonadIO m, MonadLogger m) => String -> GM.MigrationPack (DbPersist MySQL m) migrationPack currentSchema = GM.MigrationPack@@ -386,6 +388,8 @@ showAlterDb _ (AddTriggerOnUpdate schTrg trigName schTbl tName _ body) = Right [(False, triggerPriority, "CREATE TRIGGER " ++ withSchema schTrg trigName ++ " AFTER UPDATE ON " ++ withSchema schTbl tName ++ " FOR EACH ROW BEGIN " ++ body ++ "END")] showAlterDb _ (CreateOrReplaceFunction s) = Right [(False, functionPriority, s)] showAlterDb _ (DropFunction sch funcName) = Right [(False, functionPriority, "DROP FUNCTION " ++ withSchema sch funcName ++ "()")]+showAlterDb _ (CreateSchema sch ifNotExists) = Right [(False, schemaPriority, "CREATE DATABASE " ++ ifNotExists' ++ escape sch)] where+  ifNotExists' = if ifNotExists then "IF NOT EXISTS " else ""  showAlterTable :: String -> String -> AlterTable -> [(Bool, Int, String)] showAlterTable _ table (AddColumn col) = [(False, defaultPriority, concat@@ -538,11 +542,12 @@   f def = [Just def, stripQuotes def]   stripQuotes = stripPrefix "'" >=> fmap reverse . stripPrefix "'" . reverse -defaultPriority, referencePriority, functionPriority, triggerPriority :: Int-defaultPriority = 0-referencePriority = 1-functionPriority = 2-triggerPriority = 3+defaultPriority, schemaPriority, referencePriority, functionPriority, triggerPriority :: Int+defaultPriority = 1+schemaPriority = 0+referencePriority = 2+functionPriority = 3+triggerPriority = 4  mainTableId :: String mainTableId = "id"@@ -644,8 +649,8 @@ getGetter other = error $ "MySQL.getGetter: type " ++                   show other ++ " not supported." -proxy :: Proxy MySQL-proxy = error "Proxy MySQL"+proxy :: proxy MySQL+proxy = error "proxy MySQL"  noLimit :: Utf8 noLimit = "LIMIT 18446744073709551615"
+ changelog view
@@ -0,0 +1,22 @@+0.4.2.2+* Create missing schemas (or databases in MySQL terminology) during migration+* Replace datatype Proxy with type variable++0.4.2+* MySQL-specific mathematical functions (signum, quotRem)++0.4.1+* Added functions replaceBy and deleteAll++0.4.0.2+* Added createMySQLPool++0.4.0.1+* Exposed connection constructor++0.4.0+* Query logging+* Default column values++0.3.0+The first release.
groundhog-mysql.cabal view
@@ -1,5 +1,5 @@ name:            groundhog-mysql-version:         0.4.2+version:         0.4.2.2 license:         BSD3 license-file:    LICENSE author:          Boris Lykah <lykahb@gmail.com>@@ -11,13 +11,16 @@ cabal-version:   >= 1.6 build-type:      Simple +extra-source-files:+    changelog+ library     build-depends:   base                    >= 4         && < 5                    , mysql-simple            >= 0.2.2.3   && < 0.3                    , mysql                   >= 0.1.1.3   && < 0.2                    , bytestring              >= 0.9                    , transformers            >= 0.2.1-                   , groundhog               >= 0.4.2     && < 0.5.0+                   , groundhog               >= 0.4.2.2   && < 0.5.0                    , monad-control           >= 0.3                    , monad-logger            >= 0.3                    , containers              >= 0.2