From 2a03351ef0ba47a521cefe2a1f84b02956a3e2f8 Mon Sep 17 00:00:00 2001 From: Vit Guzeev Date: Wed, 24 Jan 2018 18:41:58 +0300 Subject: [PATCH 1/5] Add TODO --- TODO.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..37bb184 --- /dev/null +++ b/TODO.md @@ -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. From b20f39a8dd71a2ba8d9955448c315d60de4493d8 Mon Sep 17 00:00:00 2001 From: Vit Guzeev Date: Fri, 2 Feb 2018 12:59:05 +0300 Subject: [PATCH 2/5] Store migrations with .yml extension --- src/Database/Schema/Migrations/Filesystem.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/Schema/Migrations/Filesystem.hs b/src/Database/Schema/Migrations/Filesystem.hs index 9afca13..a4b7a61 100644 --- a/src/Database/Schema/Migrations/Filesystem.hs +++ b/src/Database/Schema/Migrations/Filesystem.hs @@ -47,7 +47,7 @@ throwFS :: String -> a throwFS = throw . FilesystemStoreError filenameExtension :: String -filenameExtension = ".txt" +filenameExtension = ".yml" filesystemStore :: FilesystemStoreSettings -> MigrationStore filesystemStore s = From ee78b9729db60c02cd699284c868cd93483c214f Mon Sep 17 00:00:00 2001 From: Vit Guzeev Date: Fri, 2 Feb 2018 13:19:45 +0300 Subject: [PATCH 3/5] Do not depend on contravariant --- dbmigrations.cabal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbmigrations.cabal b/dbmigrations.cabal index 11fda54..52bd50b 100644 --- a/dbmigrations.cabal +++ b/dbmigrations.cabal @@ -58,7 +58,7 @@ Data-Files: Source-Repository head type: git - location: git://github.com/jtdaugherty/dbmigrations.git + location: git://github.com/GetShopTV/dbmigrations.git Library default-language: Haskell2010 From 919b04c009da221bfcb74becac29a4280d636c50 Mon Sep 17 00:00:00 2001 From: Vitalii Guzeev Date: Thu, 30 Aug 2018 18:24:49 +0300 Subject: [PATCH 4/5] Convert to Stack project and freeze version of hasql --- stack.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 stack.yaml diff --git a/stack.yaml b/stack.yaml new file mode 100644 index 0000000..8ade283 --- /dev/null +++ b/stack.yaml @@ -0,0 +1,9 @@ +resolver: lts-12.8 + +packages: +- . + +extra-deps: +- HsSyck-0.53 +- yaml-light-0.1.4 +- hasql-1.1.1 From 634d9947d3fecdda906dbd1d5f0a9b827503fdab Mon Sep 17 00:00:00 2001 From: Vitalii Guzeev Date: Sat, 8 Sep 2018 23:09:07 +0300 Subject: [PATCH 5/5] Fix test suite --- dbmigrations.cabal | 30 +++++++++---------- src/Database/Schema/Migrations/Filesystem.hs | 2 +- src/Moo/CommandUtils.hs | 1 - src/Moo/Core.hs | 1 - stack.yaml | 2 +- test/FilesystemParseTest.hs | 14 ++++----- test/{TestDriver.hs => Main.hs} | 0 ..._field_name.txt => invalid_field_name.yml} | 0 ...xt => invalid_missing_required_fields.yml} | 0 ...{invalid_syntax.txt => invalid_syntax.yml} | 0 ...id_timestamp.txt => invalid_timestamp.yml} | 0 .../{valid_full.txt => valid_full.yml} | 0 ...id_no_depends.txt => valid_no_depends.yml} | 0 .../{valid_no_desc.txt => valid_no_desc.yml} | 0 ...alid_no_revert.txt => valid_no_revert.yml} | 0 ...o_timestamp.txt => valid_no_timestamp.yml} | 0 ...id_with_colon.txt => valid_with_colon.yml} | 0 ...h_comments.txt => valid_with_comments.yml} | 0 ...comments2.txt => valid_with_comments2.yml} | 0 ...deps.txt => valid_with_multiline_deps.yml} | 0 20 files changed, 24 insertions(+), 26 deletions(-) rename test/{TestDriver.hs => Main.hs} (100%) rename test/migration_parsing/{invalid_field_name.txt => invalid_field_name.yml} (100%) rename test/migration_parsing/{invalid_missing_required_fields.txt => invalid_missing_required_fields.yml} (100%) rename test/migration_parsing/{invalid_syntax.txt => invalid_syntax.yml} (100%) rename test/migration_parsing/{invalid_timestamp.txt => invalid_timestamp.yml} (100%) rename test/migration_parsing/{valid_full.txt => valid_full.yml} (100%) rename test/migration_parsing/{valid_no_depends.txt => valid_no_depends.yml} (100%) rename test/migration_parsing/{valid_no_desc.txt => valid_no_desc.yml} (100%) rename test/migration_parsing/{valid_no_revert.txt => valid_no_revert.yml} (100%) rename test/migration_parsing/{valid_no_timestamp.txt => valid_no_timestamp.yml} (100%) rename test/migration_parsing/{valid_with_colon.txt => valid_with_colon.yml} (100%) rename test/migration_parsing/{valid_with_comments.txt => valid_with_comments.yml} (100%) rename test/migration_parsing/{valid_with_comments2.txt => valid_with_comments2.yml} (100%) rename test/migration_parsing/{valid_with_multiline_deps.txt => valid_with_multiline_deps.yml} (100%) diff --git a/dbmigrations.cabal b/dbmigrations.cabal index 52bd50b..1884f7f 100644 --- a/dbmigrations.cabal +++ b/dbmigrations.cabal @@ -42,19 +42,19 @@ 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 @@ -139,7 +139,6 @@ test-suite dbmigrations-tests FilesystemTest MigrationsTest StoreTest - TestDriver InMemoryStore LinearMigrationsTest ConfigurationTest @@ -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) diff --git a/src/Database/Schema/Migrations/Filesystem.hs b/src/Database/Schema/Migrations/Filesystem.hs index a4b7a61..26e3674 100644 --- a/src/Database/Schema/Migrations/Filesystem.hs +++ b/src/Database/Schema/Migrations/Filesystem.hs @@ -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 diff --git a/src/Moo/CommandUtils.hs b/src/Moo/CommandUtils.hs index 9ef7ea6..937d535 100644 --- a/src/Moo/CommandUtils.hs +++ b/src/Moo/CommandUtils.hs @@ -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 ) diff --git a/src/Moo/Core.hs b/src/Moo/Core.hs index a07280d..3a7d391 100644 --- a/src/Moo/Core.hs +++ b/src/Moo/Core.hs @@ -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) diff --git a/stack.yaml b/stack.yaml index 8ade283..47c52ad 100644 --- a/stack.yaml +++ b/stack.yaml @@ -6,4 +6,4 @@ packages: extra-deps: - HsSyck-0.53 - yaml-light-0.1.4 -- hasql-1.1.1 +- HDBC-postgresql-2.3.2.5 diff --git a/test/FilesystemParseTest.hs b/test/FilesystemParseTest.hs index 8478ca3..2a592d0 100644 --- a/test/FilesystemParseTest.hs +++ b/test/FilesystemParseTest.hs @@ -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") ] diff --git a/test/TestDriver.hs b/test/Main.hs similarity index 100% rename from test/TestDriver.hs rename to test/Main.hs diff --git a/test/migration_parsing/invalid_field_name.txt b/test/migration_parsing/invalid_field_name.yml similarity index 100% rename from test/migration_parsing/invalid_field_name.txt rename to test/migration_parsing/invalid_field_name.yml diff --git a/test/migration_parsing/invalid_missing_required_fields.txt b/test/migration_parsing/invalid_missing_required_fields.yml similarity index 100% rename from test/migration_parsing/invalid_missing_required_fields.txt rename to test/migration_parsing/invalid_missing_required_fields.yml diff --git a/test/migration_parsing/invalid_syntax.txt b/test/migration_parsing/invalid_syntax.yml similarity index 100% rename from test/migration_parsing/invalid_syntax.txt rename to test/migration_parsing/invalid_syntax.yml diff --git a/test/migration_parsing/invalid_timestamp.txt b/test/migration_parsing/invalid_timestamp.yml similarity index 100% rename from test/migration_parsing/invalid_timestamp.txt rename to test/migration_parsing/invalid_timestamp.yml diff --git a/test/migration_parsing/valid_full.txt b/test/migration_parsing/valid_full.yml similarity index 100% rename from test/migration_parsing/valid_full.txt rename to test/migration_parsing/valid_full.yml diff --git a/test/migration_parsing/valid_no_depends.txt b/test/migration_parsing/valid_no_depends.yml similarity index 100% rename from test/migration_parsing/valid_no_depends.txt rename to test/migration_parsing/valid_no_depends.yml diff --git a/test/migration_parsing/valid_no_desc.txt b/test/migration_parsing/valid_no_desc.yml similarity index 100% rename from test/migration_parsing/valid_no_desc.txt rename to test/migration_parsing/valid_no_desc.yml diff --git a/test/migration_parsing/valid_no_revert.txt b/test/migration_parsing/valid_no_revert.yml similarity index 100% rename from test/migration_parsing/valid_no_revert.txt rename to test/migration_parsing/valid_no_revert.yml diff --git a/test/migration_parsing/valid_no_timestamp.txt b/test/migration_parsing/valid_no_timestamp.yml similarity index 100% rename from test/migration_parsing/valid_no_timestamp.txt rename to test/migration_parsing/valid_no_timestamp.yml diff --git a/test/migration_parsing/valid_with_colon.txt b/test/migration_parsing/valid_with_colon.yml similarity index 100% rename from test/migration_parsing/valid_with_colon.txt rename to test/migration_parsing/valid_with_colon.yml diff --git a/test/migration_parsing/valid_with_comments.txt b/test/migration_parsing/valid_with_comments.yml similarity index 100% rename from test/migration_parsing/valid_with_comments.txt rename to test/migration_parsing/valid_with_comments.yml diff --git a/test/migration_parsing/valid_with_comments2.txt b/test/migration_parsing/valid_with_comments2.yml similarity index 100% rename from test/migration_parsing/valid_with_comments2.txt rename to test/migration_parsing/valid_with_comments2.yml diff --git a/test/migration_parsing/valid_with_multiline_deps.txt b/test/migration_parsing/valid_with_multiline_deps.yml similarity index 100% rename from test/migration_parsing/valid_with_multiline_deps.txt rename to test/migration_parsing/valid_with_multiline_deps.yml