postgresql-simple-migration 0.1.10.1 → 0.1.11.0
raw patch · 5 files changed
+22/−5 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Changelog.markdown +4/−0
- postgresql-simple-migration.cabal +1/−1
- src/Database/PostgreSQL/Simple/Migration.hs +2/−2
- src/Database/PostgreSQL/Simple/Util.hs +5/−1
- test/Database/PostgreSQL/Simple/MigrationTest.hs +10/−1
Changelog.markdown view
@@ -1,5 +1,9 @@ # Changelog +## 0.1.11.0+* Improved documentation+* Fixed exists_table+ ## 0.1.10.1 * Fixed hackage warnings
postgresql-simple-migration.cabal view
@@ -1,5 +1,5 @@ name: postgresql-simple-migration-version: 0.1.10.1+version: 0.1.11.0 synopsis: PostgreSQL Schema Migrations homepage: https://github.com/ameingast/postgresql-simple-migration Bug-reports: https://github.com/ameingast/postgresql-simple-migration/issues
src/Database/PostgreSQL/Simple/Migration.hs view
@@ -47,8 +47,8 @@ import qualified Data.ByteString as BS (ByteString, readFile) import qualified Data.ByteString.Base64 as B64 (encode) import Data.Foldable (Foldable)-import Data.Traversable (Traversable) import Data.List (isPrefixOf, sort)+import Data.Traversable (Traversable) #if __GLASGOW_HASKELL__ < 710 import Data.Monoid (Monoid (..)) #endif@@ -250,7 +250,7 @@ | MigrationScript ScriptName BS.ByteString -- ^ Executes a migration based on the provided bytestring. | MigrationValidation MigrationCommand- -- ^ Validates the provided MigrationCommand.+ -- ^ Validates that the provided MigrationCommand has been executed. | MigrationCommands [MigrationCommand] -- ^ Performs a series of 'MigrationCommand's in sequence. deriving (Show, Eq, Read, Ord)
src/Database/PostgreSQL/Simple/Util.hs view
@@ -25,9 +25,13 @@ -- | Checks if the table with the given name exists in the database. existsTable :: Connection -> String -> IO Bool existsTable con table =- fmap (not . null) (query con q (Only table) :: IO [[Int]])+ fmap checkRowCount (query con q (Only table) :: IO [[Int]]) where q = "select count(relname) from pg_class where relname = ?"++ checkRowCount :: [[Int]] -> Bool+ checkRowCount ((1:_):_) = True+ checkRowCount _ = False -- | Executes the given IO monad inside a transaction and performs a roll-back -- afterwards (even if exceptions occur).
test/Database/PostgreSQL/Simple/MigrationTest.hs view
@@ -33,12 +33,21 @@ let migrationDir = MigrationDirectory "share/test/scripts" let migrationFile = MigrationFile "s.sql" "share/test/script.sql" + it "asserts that the schema_migrations table does not exist" $ do+ r <- existsTable con "schema_migrations"+ r `shouldBe` False++ it "validates an initialization on an empty database" $ do+ r <- runMigration $ MigrationContext+ (MigrationValidation MigrationInitialization) False con+ r `shouldBe` MigrationError "No such table: schema_migrations"+ it "initializes a database" $ do r <- runMigration $ MigrationContext MigrationInitialization False con r `shouldBe` MigrationSuccess it "creates the schema_migrations table" $ do- r <- existsTable con "schema_migration"+ r <- existsTable con "schema_migrations" r `shouldBe` True it "executes a migration script" $ do