packages feed

dbmigrations-sqlite (empty) → 2.0.0

raw patch · 5 files changed

+169/−0 lines, 5 filesdep +HDBCdep +HDBC-sqlite3dep +HUnitsetup-changed

Dependencies added: HDBC, HDBC-sqlite3, HUnit, base, dbmigrations

Files

+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2009, Jonathan Daugherty.+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * The names of the contributors may not be used to endorse or+      promote products derived from this software without specific+      prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ dbmigrations-sqlite.cabal view
@@ -0,0 +1,64 @@+Name:                dbmigrations-sqlite+Version:             2.0.0+Synopsis:            The dbmigrations tool built for SQLite databases+Description:         This package contains the executable to work with+                     the dbmigrations package when the database backend+                     is SQLite. See the package dbmigrations for details+                     about the dbmigrations project in general.++                     To get started, see the 'README.md'+                     (https://github.com/jtdaugherty/dbmigrations/blob/master/README.md)+                     and 'MOO.TXT'+                     (https://github.com/jtdaugherty/dbmigrations/blob/master/MOO.TXT)+                     files included in the dbmigrations package and the+                     usage output for the 'moo-sqlite' command.++Category:            Database+Author:              Jonathan Daugherty <cygnus@foobox.com>+Maintainer:          Jonathan Daugherty <cygnus@foobox.com>+Build-Type:          Simple+License:             BSD3+License-File:        LICENSE+Cabal-Version:       >= 1.10++Source-Repository head+  type:     git+  location: git://github.com/jtdaugherty/dbmigrations-sqlite.git++Executable moo-sqlite+  default-language: Haskell2010+  Build-Depends:+    base >= 4 && < 5,+    dbmigrations >= 2,+    HDBC-sqlite3++  if impl(ghc >= 6.12.0)+    ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields+                 -fno-warn-unused-do-bind+  else+    ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields++  Hs-Source-Dirs:  programs+  Main-is:         MooSQLite.hs++test-suite dbmigrations-sqlite-tests+  default-language: Haskell2010+  type: exitcode-stdio-1.0+  Build-Depends:+    base >= 4 && < 5,+    dbmigrations >= 2,+    HDBC >= 2.2.1,+    HDBC-sqlite3 == 2.3.3.1,+    HUnit >= 1.2++  other-modules:+    TestDriver++  if impl(ghc >= 6.12.0)+    ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields+                 -fno-warn-unused-do-bind -Wwarn+  else+    ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields++  Hs-Source-Dirs:  test+  Main-is:         TestDriver.hs
+ programs/MooSQLite.hs view
@@ -0,0 +1,28 @@+module Main+    ( main+    )+where++import Database.HDBC.Sqlite3 (connectSqlite3)+import Prelude  hiding (lookup)+import System.Environment (getArgs)+import System.Exit++import Database.Schema.Migrations.Backend.HDBC (hdbcBackend)+import Moo.Core+import Moo.Main++main :: IO ()+main = do+  args <- getArgs+  (_, opts, _) <- procArgs args+  loadedConf <- loadConfiguration $ _configFilePath opts+  case loadedConf of+    Left e -> putStrLn e >> exitFailure+    Right conf -> do+      let connectionString = _connectionString conf+      connection <- connectSqlite3 connectionString+      let backend = hdbcBackend connection+          parameters = makeParameters conf backend+      mainWithParameters args parameters+
+ test/TestDriver.hs view
@@ -0,0 +1,45 @@+{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE ScopedTypeVariables #-}+module Main where++import Database.Schema.Migrations.Backend.HDBC (hdbcBackend)+import Database.Schema.Migrations.Test.BackendTest as BackendTest++import Control.Exception (Handler(..), catches, finally )+import Database.HDBC ( IConnection(disconnect) )+import qualified Database.HDBC as HDBC+import Database.HDBC.Sqlite3 ( connectSqlite3 )+import System.Exit+import System.IO ( stderr )+import Test.HUnit++data SQLiteBackendConnection =+    forall a. HDBC.IConnection a => HDBCConnection a++instance BackendConnection SQLiteBackendConnection where+    supportsTransactionalDDL = const True+    makeBackend (HDBCConnection c) = hdbcBackend c+    commit (HDBCConnection c) = HDBC.commit c+    withTransaction (HDBCConnection c) transaction =+        HDBC.withTransaction c (transaction . HDBCConnection)+    getTables (HDBCConnection c) = HDBC.getTables c+    catchAll (HDBCConnection _) act handler =+        act `catches` [ Handler (\(_ :: HDBC.SqlError) -> handler) ]++loadTests :: IO [Test]+loadTests = do++  sqliteConn <- connectSqlite3 ":memory:"+  let backendConnection :: SQLiteBackendConnection = HDBCConnection sqliteConn+      testAct = (BackendTest.tests backendConnection)+                `finally`+                (disconnect sqliteConn)+  return [ ("SQLite backend tests") ~: test testAct ]++main :: IO ()+main = do+  tests_ <- loadTests+  (testResults, _) <- runTestText (putTextToHandle stderr False) $ test tests_+  if errors testResults + failures testResults > 0+    then exitFailure+    else exitSuccess