Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Move back to HDBC #34

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* learn HaSQL parametric queries and use here.
* update tests.
* pretty print error messages.
* and check if I can run out of multicommand string here - learn how does sqitch do it.
32 changes: 16 additions & 16 deletions dbmigrations.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ Data-Files:
test/config_loading/invalid.cfg
test/config_loading/missing.cfg
test/config_loading/moo.cfg
test/migration_parsing/invalid_field_name.txt
test/migration_parsing/invalid_missing_required_fields.txt
test/migration_parsing/invalid_syntax.txt
test/migration_parsing/invalid_timestamp.txt
test/migration_parsing/valid_full.txt
test/migration_parsing/valid_no_depends.txt
test/migration_parsing/valid_no_desc.txt
test/migration_parsing/valid_no_revert.txt
test/migration_parsing/valid_no_timestamp.txt
test/migration_parsing/valid_with_colon.txt
test/migration_parsing/valid_with_comments.txt
test/migration_parsing/valid_with_comments2.txt
test/migration_parsing/valid_with_multiline_deps.txt
test/migration_parsing/invalid_field_name.yml
test/migration_parsing/invalid_missing_required_fields.yml
test/migration_parsing/invalid_syntax.yml
test/migration_parsing/invalid_timestamp.yml
test/migration_parsing/valid_full.yml
test/migration_parsing/valid_no_depends.yml
test/migration_parsing/valid_no_desc.yml
test/migration_parsing/valid_no_revert.yml
test/migration_parsing/valid_no_timestamp.yml
test/migration_parsing/valid_with_colon.yml
test/migration_parsing/valid_with_comments.yml
test/migration_parsing/valid_with_comments2.yml
test/migration_parsing/valid_with_multiline_deps.yml

Source-Repository head
type: git
location: git://github.com/jtdaugherty/dbmigrations.git
location: git://github.com/GetShopTV/dbmigrations.git

Library
default-language: Haskell2010
Expand Down Expand Up @@ -139,7 +139,6 @@ test-suite dbmigrations-tests
FilesystemTest
MigrationsTest
StoreTest
TestDriver
InMemoryStore
LinearMigrationsTest
ConfigurationTest
Expand All @@ -151,13 +150,14 @@ test-suite dbmigrations-tests
ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields

Hs-Source-Dirs: src,test
Main-is: TestDriver.hs
Main-is: Main.hs

Executable moo
default-language: Haskell2010
Build-Depends:
base >= 4 && < 5,
configurator >= 0.2,
HDBC-postgresql >= 2.2.1,
dbmigrations

if impl(ghc >= 6.12.0)
Expand Down
28 changes: 19 additions & 9 deletions programs/Moo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ module Main
)
where

import Prelude
import Database.HDBC.PostgreSQL (connectPostgreSQL)
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
error $
"This package (dbmigrations) does no longer contain the executable to \
\create, apply or revert database migrations. Please install the specific \
\wrapper package for your database: dbmigrations-postgresql, \
\dbmigrations-mysql, or dbmigrations-sqlite. These packages contain \
\database-specific executables that replace the former moo executable from the \
\dbmigrations package."

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 <- connectPostgreSQL connectionString
let backend = hdbcBackend connection
parameters = makeParameters conf backend
mainWithParameters args parameters
4 changes: 2 additions & 2 deletions src/Database/Schema/Migrations/Filesystem.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Database.Schema.Migrations.Filesystem
)
where

import Prelude hiding ( catch )
import Prelude

import System.Directory ( getDirectoryContents, doesFileExist )
import System.FilePath ( (</>), takeExtension, dropExtension
Expand Down Expand Up @@ -47,7 +47,7 @@ throwFS :: String -> a
throwFS = throw . FilesystemStoreError

filenameExtension :: String
filenameExtension = ".txt"
filenameExtension = ".yml"

filesystemStore :: FilesystemStoreSettings -> MigrationStore
filesystemStore s =
Expand Down
1 change: 0 additions & 1 deletion src/Moo/CommandUtils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module Moo.CommandUtils
, getCurrentTimestamp
) where

import Control.Applicative
import Control.Exception ( finally )
import Control.Monad ( when, forM_, unless )
import Control.Monad.Reader ( asks )
Expand Down
1 change: 0 additions & 1 deletion src/Moo/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module Moo.Core
, envStoreName
, loadConfiguration) where

import Control.Applicative
import Control.Monad.Reader (ReaderT)
import qualified Data.Configurator as C
import Data.Configurator.Types (Config, Configured)
Expand Down
9 changes: 9 additions & 0 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resolver: lts-12.8

packages:
- .

extra-deps:
- HsSyck-0.53
- yaml-light-0.1.4
- HDBC-postgresql-2.3.2.5
14 changes: 7 additions & 7 deletions test/FilesystemParseTest.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,27 @@ migrationParsingTestCases = [ ("valid_full", Right valid_full)
, Right (valid_full { mId = "valid_no_timestamp", mTimestamp = Nothing }))
, ("invalid_missing_required_fields"
, Left $ "Could not parse migration " ++
(fp "invalid_missing_required_fields.txt") ++
(fp "invalid_missing_required_fields.yml") ++
":Error in " ++
(show $ fp "invalid_missing_required_fields.txt") ++
(show $ fp "invalid_missing_required_fields.yml") ++
": missing required field(s): " ++
"[\"Depends\"]")
, ("invalid_field_name"
, Left $ "Could not parse migration " ++
(fp "invalid_field_name.txt") ++
(fp "invalid_field_name.yml") ++
":Error in " ++
(show $ fp "invalid_field_name.txt") ++
(show $ fp "invalid_field_name.yml") ++
": unrecognized field found")
, ("invalid_syntax"
, Left $ "Could not parse migration " ++
(fp "invalid_syntax.txt") ++
(fp "invalid_syntax.yml") ++
":user error (syntax error: line 7, " ++
"column 0)")
, ("invalid_timestamp"
, Left $ "Could not parse migration " ++
(fp "invalid_timestamp.txt") ++
(fp "invalid_timestamp.yml") ++
":Error in " ++
(show $ fp "invalid_timestamp.txt") ++
(show $ fp "invalid_timestamp.yml") ++
": unrecognized field found")
]

Expand Down
File renamed without changes.