diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 000000000..e1a43c5f2 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,8 @@ +{ + "permissions": { + "allow": [ + "Bash(ghc:*)", + "Bash(git stash:*)" + ] + } +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..7e257db92 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": [] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..c7efda6e9 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,50 @@ + +{ + // Automatically created by phoityne-vscode extension. + + "version": "2.0.0", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "tasks": [ + { + // F7 + "group": { + "kind": "build", + "isDefault": true + }, + "label": "haskell build", + "type": "shell", + //"command": "cabal configure && cabal build" + "command": "stack build" + }, + { + // F6 + "group": "build", + "type": "shell", + "label": "haskell clean & build", + //"command": "cabal clean && cabal configure && cabal build" + "command": "stack clean && stack build" + //"command": "stack clean ; stack build" // for powershell + }, + { + // F8 + "group": { + "kind": "test", + "isDefault": true + }, + "type": "shell", + "label": "haskell test", + //"command": "cabal test" + "command": "stack test" + }, + { + // F6 + "isBackground": true, + "type": "shell", + "label": "haskell watch", + "command": "stack build --test --no-run-tests --file-watch" + } + ] +} diff --git a/beam-core/Database/Beam/Backend/SQL/Row.hs b/beam-core/Database/Beam/Backend/SQL/Row.hs index c2e9cb5b4..bd735314e 100644 --- a/beam-core/Database/Beam/Backend/SQL/Row.hs +++ b/beam-core/Database/Beam/Backend/SQL/Row.hs @@ -25,6 +25,7 @@ import Control.Applicative import Control.Exception (Exception) import Control.Monad.Free.Church import Control.Monad.Identity +import Control.Monad (replicateM_) import Data.Tagged import Data.Typeable import Data.Vector.Sized (Vector) @@ -277,13 +278,13 @@ instance ( BeamBackend be, Generic (tbl (Nullable Identity)), Generic (tbl (Null valuesNeeded be _ = gValuesNeeded be (Proxy @(Rep (tbl (Nullable Exposed)))) (Proxy @(Rep (tbl (Nullable Identity)))) instance (FromBackendRow be x, FromBackendRow be SqlNull) => FromBackendRow be (Maybe x) where - fromBackendRow = - (Just <$> fromBackendRow) <|> - (Nothing <$ - replicateM_ (valuesNeeded (Proxy @be) (Proxy @(Maybe x))) - (do SqlNull <- fromBackendRow - pure ())) - valuesNeeded be _ = valuesNeeded be (Proxy @x) + fromBackendRow = + (Just <$> fromBackendRow) <|> + (Nothing <$ + replicateM_ (valuesNeeded (Proxy @be) (Proxy @(Maybe x))) + (do SqlNull <- fromBackendRow + pure ())) + valuesNeeded be _ = valuesNeeded be (Proxy @x) instance (BeamBackend be, FromBackendRow be t) => FromBackendRow be (Tagged tag t) where fromBackendRow = Tagged <$> fromBackendRow diff --git a/beam-core/Database/Beam/Backend/SQL/SQL92.hs b/beam-core/Database/Beam/Backend/SQL/SQL92.hs index 1dcf8f870..87af8d142 100644 --- a/beam-core/Database/Beam/Backend/SQL/SQL92.hs +++ b/beam-core/Database/Beam/Backend/SQL/SQL92.hs @@ -118,7 +118,6 @@ class ( IsSql92ExpressionSyntax (Sql92SelectTableExpressionSyntax select) , IsSql92FromSyntax (Sql92SelectTableFromSyntax select) , IsSql92GroupingSyntax (Sql92SelectTableGroupingSyntax select) , IsSql92AggregationSetQuantifierSyntax (Sql92SelectTableSetQuantifierSyntax select) - , IsSql92AggregationIndexHintsSyntax (Sql92SelectTableSetIndexHintsSyntax select) , Sql92GroupingExpressionSyntax (Sql92SelectTableGroupingSyntax select) ~ Sql92SelectTableExpressionSyntax select , Sql92FromExpressionSyntax (Sql92SelectTableFromSyntax select) ~ Sql92SelectTableExpressionSyntax select diff --git a/beam-core/Database/Beam/Query/CTE.hs b/beam-core/Database/Beam/Query/CTE.hs index 767bc104a..c10a4a425 100644 --- a/beam-core/Database/Beam/Query/CTE.hs +++ b/beam-core/Database/Beam/Query/CTE.hs @@ -9,6 +9,8 @@ import Database.Beam.Query.Internal import Database.Beam.Query.Types import Control.Monad.Free.Church +import Control.Monad.Fix (MonadFix(..)) + import Control.Monad.Writer hiding ((<>)) import Control.Monad.State.Strict diff --git a/beam-core/Database/Beam/Schema/Lenses.hs b/beam-core/Database/Beam/Schema/Lenses.hs index 162b40f6b..58d7dca87 100644 --- a/beam-core/Database/Beam/Schema/Lenses.hs +++ b/beam-core/Database/Beam/Schema/Lenses.hs @@ -16,6 +16,7 @@ import Database.Beam.Schema.Tables import Control.Monad.Identity import Data.Proxy +import Data.Function (fix) import GHC.Generics import GHC.Types (Type) diff --git a/beam-core/flake.lock b/beam-core/flake.lock new file mode 100644 index 000000000..121f50fac --- /dev/null +++ b/beam-core/flake.lock @@ -0,0 +1,77 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/beam-core/flake.nix b/beam-core/flake.nix new file mode 100644 index 000000000..2aa695336 --- /dev/null +++ b/beam-core/flake.nix @@ -0,0 +1,33 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/89c2b2330e733d6cdb5eae7b899326930c2c0648"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + }; + + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, ... }: { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.haskell-flake.flakeModule + ]; + perSystem = { self', pkgs, lib, config, ... }: { + haskellProjects.default = { + projectFlakeName = "beam"; + basePackages = pkgs.haskell.packages.ghc98; + autoWire = ["packages" "checks" "devShells" "apps"]; + devShell.tools = hp: { + "haskell-language-server" = null; + }; + packages ={ + pqueue.source = "1.5.0.0"; + }; + settings = { + pretty-simple = { + check = false; + }; + }; + }; + }; + }); +} diff --git a/beam-migrate-cli/Database/Beam/Migrate/Tool/Registry.hs b/beam-migrate-cli/Database/Beam/Migrate/Tool/Registry.hs index f56b6d25a..9849ef823 100644 --- a/beam-migrate-cli/Database/Beam/Migrate/Tool/Registry.hs +++ b/beam-migrate-cli/Database/Beam/Migrate/Tool/Registry.hs @@ -330,7 +330,7 @@ lookupUserInfo _ = do let fullName = username #else userId <- getEffectiveUserID - UserEntry { userName = username, userGecos = fullName } <- getUserEntryForID userId + UserEntry username _ _ _ fullName _ _ <- getUserEntryForID userId #endif hostname <- getHostName diff --git a/beam-migrate-cli/flake.lock b/beam-migrate-cli/flake.lock new file mode 100644 index 000000000..e5ce61a9c --- /dev/null +++ b/beam-migrate-cli/flake.lock @@ -0,0 +1,323 @@ +{ + "nodes": { + "beam-core": { + "inputs": { + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-u4F8QoNRHbQ5MTSd9VGsI9xu4eT7L+hI1pjrvZ+nqdU=", + "path": "../beam-core", + "type": "path" + }, + "original": { + "path": "../beam-core", + "type": "path" + } + }, + "beam-core_2": { + "inputs": { + "flake-parts": "flake-parts_2", + "haskell-flake": "haskell-flake_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-u4F8QoNRHbQ5MTSd9VGsI9xu4eT7L+hI1pjrvZ+nqdU=", + "path": "../beam-core", + "type": "path" + }, + "original": { + "path": "../beam-core", + "type": "path" + } + }, + "beam-migrate": { + "inputs": { + "beam-core": "beam-core_2", + "flake-parts": "flake-parts_3", + "haskell-flake": "haskell-flake_3", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-Y3SXjn+Qa6KnQVuZP5l/Lv1Zruyjz6OhuPs7qtppWC8=", + "path": "../beam-migrate", + "type": "path" + }, + "original": { + "path": "../beam-migrate", + "type": "path" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_3" + }, + "locked": { + "lastModified": 1768135262, + "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_4": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_4" + }, + "locked": { + "lastModified": 1767609335, + "narHash": "sha256-feveD98mQpptwrAEggBQKJTYbvwwglSbOv53uCfH9PY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "250481aafeb741edfe23d29195671c19b36b6dca", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_2": { + "locked": { + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_3": { + "locked": { + "lastModified": 1769355516, + "narHash": "sha256-HHoaDIz42Yfd4Ll8ik9tYN3Q/77hesaNhD/GZ/ZZzD0=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "692b0799558e361a9029541f0630c91b8dc96744", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_4": { + "locked": { + "lastModified": 1767640826, + "narHash": "sha256-017M+QPfv4DzB0BYUvoeTmJ9+r6C8cwt3kr88eMu16I=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "70b04dd7cc87d038aa31f911cb4d231c5afa93ee", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_2": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_3": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_4": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "root": { + "inputs": { + "beam-core": "beam-core", + "beam-migrate": "beam-migrate", + "flake-parts": "flake-parts_4", + "haskell-flake": "haskell-flake_4", + "nixpkgs": "nixpkgs_4" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/beam-migrate-cli/flake.nix b/beam-migrate-cli/flake.nix new file mode 100644 index 000000000..a4ecf81be --- /dev/null +++ b/beam-migrate-cli/flake.nix @@ -0,0 +1,36 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/89c2b2330e733d6cdb5eae7b899326930c2c0648"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + beam-core.url = "path:../beam-core"; + beam-migrate.url = "path:../beam-migrate"; + }; + + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, ... }: { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.haskell-flake.flakeModule + ]; + perSystem = { self', pkgs, lib, config, ... }: { + haskellProjects.default = { + projectFlakeName = "beam"; + basePackages = pkgs.haskell.packages.ghc98; + autoWire = ["packages" "checks" "devShells" "apps"]; + devShell.tools = hp: { + "haskell-language-server" = null; + }; + packages = { + beam-core.source = inputs.beam-core; + beam-migrate.source = inputs.beam-migrate; + }; + settings = { + pretty-simple = { + check = false; + }; + }; + }; + }; + }); +} diff --git a/beam-migrate/Database/Beam/Haskell/Syntax.hs b/beam-migrate/Database/Beam/Haskell/Syntax.hs index f8b81b3f2..b290a1b67 100644 --- a/beam-migrate/Database/Beam/Haskell/Syntax.hs +++ b/beam-migrate/Database/Beam/Haskell/Syntax.hs @@ -23,6 +23,7 @@ import Database.Beam.Migrate.Serialization import Data.Char (toLower, toUpper) import Data.Hashable +import Data.Int (Int32) import Data.List (find, nub) import qualified Data.Map as M import Data.Maybe @@ -667,8 +668,8 @@ instance IsSql92ExpressionSyntax HsExpr where lowerE = hsApp (hsVar "lowerE") . pure upperE = hsApp (hsVar "upperE") . pure trimE = hsApp (hsVar "trimE") . pure - jsonValidE = hsApp (hsVar "jsonValidE") . pure - jsonUnquoteE = hsApp (hsVar "jsonUnquoteE") . pure + -- jsonValidE = hsApp (hsVar "jsonValidE") . pure + -- jsonUnquoteE = hsApp (hsVar "jsonUnquoteE") . pure existsE = error "existsE" uniqueE = error "uniqueE" @@ -679,7 +680,7 @@ instance IsSql92ExpressionSyntax HsExpr where castE = error "castE" extractE = error "extractE" - jsonExtractE = error "jsonExtractE" + -- jsonExtractE = error "jsonExtractE" isNullE = hsApp (hsVar "isNullE") . pure isNotNullE = hsApp (hsVar "isNotNullE") . pure @@ -723,6 +724,9 @@ instance IsSql92ConstraintAttributesSyntax HsNone where instance HasSqlValueSyntax HsExpr Int where sqlValueSyntax = hsInt +instance HasSqlValueSyntax HsExpr Int32 where + sqlValueSyntax = hsInt + instance HasSqlValueSyntax HsExpr T.Text where sqlValueSyntax = hsStr diff --git a/beam-migrate/Database/Beam/Migrate/Log.hs b/beam-migrate/Database/Beam/Migrate/Log.hs index 1d987d7b6..e6d5d57fe 100644 --- a/beam-migrate/Database/Beam/Migrate/Log.hs +++ b/beam-migrate/Database/Beam/Migrate/Log.hs @@ -117,6 +117,7 @@ updateSchemaToCurrent :: forall be m . ( BeamMigrateSqlBackend be , HasDataTypeCreatedCheck (BeamMigrateSqlBackendDataTypeSyntax be) , BeamSqlBackendCanSerialize be Text + , BeamSqlBackendCanSerialize be Int , MonadBeam be m ) => m () updateSchemaToCurrent = @@ -128,6 +129,7 @@ recordCommit :: forall be m , BeamSqlBackendSupportsDataType be Text , BeamSqlBackendCanDeserialize be Int , BeamSqlBackendCanDeserialize be LocalTime + , BeamSqlBackendCanSerialize be Int , HasQBuilder be , MonadBeam be m ) => UUID -> m () @@ -145,7 +147,10 @@ recordCommit commitId = do -- Ensure the backend tables exist ensureBackendTables :: forall be m - . (BeamSqlBackendCanSerialize be Text, Fail.MonadFail m) + . ( BeamSqlBackendCanSerialize be Text + , BeamSqlBackendCanSerialize be Int + , BeamSqlBackendCanDeserialize be Int + , Fail.MonadFail m ) => BeamMigrationBackend be m -> m () ensureBackendTables be@BeamMigrationBackend { backendGetDbConstraints = getCs } = diff --git a/beam-migrate/Database/Beam/Migrate/SQL/Tables.hs b/beam-migrate/Database/Beam/Migrate/SQL/Tables.hs index d4cd077b9..4fb633caa 100644 --- a/beam-migrate/Database/Beam/Migrate/SQL/Tables.hs +++ b/beam-migrate/Database/Beam/Migrate/SQL/Tables.hs @@ -46,6 +46,7 @@ import Control.Applicative import Control.Monad.Identity import Control.Monad.Writer.Strict import Control.Monad.State +import Control.Monad (forM_) import Data.Text (Text) import Data.Typeable diff --git a/beam-migrate/Database/Beam/Migrate/Simple.hs b/beam-migrate/Database/Beam/Migrate/Simple.hs index 1be16c2d5..8ed4cd3c8 100644 --- a/beam-migrate/Database/Beam/Migrate/Simple.hs +++ b/beam-migrate/Database/Beam/Migrate/Simple.hs @@ -96,7 +96,9 @@ defaultUpToDateHooks = -- Tries to bring the database up to date, using the database log and the given -- 'MigrationSteps'. Fails if the migration is irreversible, or an error occurs. bringUpToDate :: ( Database be db, Fail.MonadFail m - , HasDataTypeCreatedCheck (BeamMigrateSqlBackendDataTypeSyntax be) ) + , HasDataTypeCreatedCheck (BeamMigrateSqlBackendDataTypeSyntax be) + , BeamSqlBackendCanSerialize be Int + , BeamSqlBackendCanDeserialize be Int ) => BeamMigrationBackend be m -> MigrationSteps be () (CheckedDatabaseSettings be db) -> m (Maybe (CheckedDatabaseSettings be db)) @@ -112,7 +114,9 @@ bringUpToDate be@BeamMigrationBackend {} = -- with 'defaultUpToDateHooks' is the same as using 'bringUpToDate'. bringUpToDateWithHooks :: forall db be m . ( Database be db, Fail.MonadFail m - , HasDataTypeCreatedCheck (BeamMigrateSqlBackendDataTypeSyntax be) ) + , HasDataTypeCreatedCheck (BeamMigrateSqlBackendDataTypeSyntax be) + , BeamSqlBackendCanSerialize be Int + , BeamSqlBackendCanDeserialize be Int ) => BringUpToDateHooks m -> BeamMigrationBackend be m -> MigrationSteps be () (CheckedDatabaseSettings be db) diff --git a/beam-migrate/Database/Beam/Migrate/Types/CheckedEntities.hs b/beam-migrate/Database/Beam/Migrate/Types/CheckedEntities.hs index 3a2d145b1..fa169704f 100644 --- a/beam-migrate/Database/Beam/Migrate/Types/CheckedEntities.hs +++ b/beam-migrate/Database/Beam/Migrate/Types/CheckedEntities.hs @@ -14,11 +14,12 @@ import Database.Beam.Migrate.Types.Predicates import Control.Applicative import Control.Monad.Writer import Control.Monad.Identity +import Control.Monad (forM_) import Data.Proxy import Data.Text (Text) import Data.String - +import Data.Semigroup (Endo(..)) import GHC.Types import GHC.Generics diff --git a/beam-migrate/flake.lock b/beam-migrate/flake.lock new file mode 100644 index 000000000..393dfb6e3 --- /dev/null +++ b/beam-migrate/flake.lock @@ -0,0 +1,159 @@ +{ + "nodes": { + "beam-core": { + "inputs": { + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-u4F8QoNRHbQ5MTSd9VGsI9xu4eT7L+hI1pjrvZ+nqdU=", + "path": "../beam-core", + "type": "path" + }, + "original": { + "path": "../beam-core", + "type": "path" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1768135262, + "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_2": { + "locked": { + "lastModified": 1769355516, + "narHash": "sha256-HHoaDIz42Yfd4Ll8ik9tYN3Q/77hesaNhD/GZ/ZZzD0=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "692b0799558e361a9029541f0630c91b8dc96744", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_2": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "root": { + "inputs": { + "beam-core": "beam-core", + "flake-parts": "flake-parts_2", + "haskell-flake": "haskell-flake_2", + "nixpkgs": "nixpkgs_2" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/beam-migrate/flake.nix b/beam-migrate/flake.nix new file mode 100644 index 000000000..adb1a95ab --- /dev/null +++ b/beam-migrate/flake.nix @@ -0,0 +1,34 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/89c2b2330e733d6cdb5eae7b899326930c2c0648"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + beam-core.url = "path:../beam-core"; + }; + + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, ... }: { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.haskell-flake.flakeModule + ]; + perSystem = { self', pkgs, lib, config, ... }: { + haskellProjects.default = { + projectFlakeName = "beam"; + basePackages = pkgs.haskell.packages.ghc98; + autoWire = ["packages" "checks" "devShells" "apps"]; + devShell.tools = hp: { + "haskell-language-server" = null; + }; + packages = { + beam-core.source = inputs.beam-core; + }; + settings = { + pretty-simple = { + check = false; + }; + }; + }; + }; + }); +} diff --git a/beam-postgres/Database/Beam/Postgres/Connection.hs b/beam-postgres/Database/Beam/Postgres/Connection.hs index 29ed354e5..7dfd3a892 100644 --- a/beam-postgres/Database/Beam/Postgres/Connection.hs +++ b/beam-postgres/Database/Beam/Postgres/Connection.hs @@ -57,6 +57,7 @@ import qualified Database.PostgreSQL.Simple.Types as Pg (Query(..)) import Control.Monad.Reader import Control.Monad.State import qualified Control.Monad.Fail as Fail +import Control.Monad(foldM) import Data.ByteString (ByteString) import Data.ByteString.Builder (toLazyByteString, byteString) diff --git a/beam-postgres/Database/Beam/Postgres/Syntax.hs b/beam-postgres/Database/Beam/Postgres/Syntax.hs index fce05885e..503e15f00 100644 --- a/beam-postgres/Database/Beam/Postgres/Syntax.hs +++ b/beam-postgres/Database/Beam/Postgres/Syntax.hs @@ -87,6 +87,7 @@ module Database.Beam.Postgres.Syntax import Database.Beam hiding (insert) import Database.Beam.Backend.SQL +import Database.Beam.Backend.SQL.SQL92 import Database.Beam.Migrate import Database.Beam.Migrate.Checks (HasDataTypeCreatedCheck(..)) import Database.Beam.Migrate.SQL.Builder hiding (fromSqlConstraintAttributes) @@ -457,7 +458,6 @@ instance IsSql92SelectSyntax PgSelectSyntax where instance IsSql92SelectTableSyntax PgSelectTableSyntax where type Sql92SelectTableSelectSyntax PgSelectTableSyntax = PgSelectSyntax - type Sql92SelectTableSetIndexHintsSyntax PgSelectTableSyntax = PgExpressionSyntax type Sql92SelectTableExpressionSyntax PgSelectTableSyntax = PgExpressionSyntax type Sql92SelectTableProjectionSyntax PgSelectTableSyntax = PgProjectionSyntax type Sql92SelectTableFromSyntax PgSelectTableSyntax = PgFromSyntax @@ -673,9 +673,11 @@ mkNumericPrec :: Maybe (Word, Maybe Word) -> Maybe Int32 mkNumericPrec Nothing = Nothing mkNumericPrec (Just (whole, dec)) = Just $ (fromIntegral whole `shiftL` 16) .|. (fromIntegral (fromMaybe 0 dec) .&. 0xFFFF) -instance IsSql92AggregationIndexHintsSyntax PgExpressionSyntax where - setIndexForce = error "Not Implemented for postgress" - setIndexUse = error "Not Implemented for postgress" +instance IsSql92AggregationIndexHintsSyntax PgAggregationSetQuantifierSyntax where + type Sql92AggregationIndexHintsSyntax PgAggregationSetQuantifierSyntax = PgExpressionSyntax + + setIndexForce = const (PgAggregationSetQuantifierSyntax mempty) + setIndexUse = const (PgAggregationSetQuantifierSyntax mempty) instance IsCustomSqlSyntax PgExpressionSyntax where newtype CustomSqlSyntax PgExpressionSyntax = diff --git a/beam-postgres/flake.lock b/beam-postgres/flake.lock new file mode 100644 index 000000000..94e95b942 --- /dev/null +++ b/beam-postgres/flake.lock @@ -0,0 +1,241 @@ +{ + "nodes": { + "beam-core": { + "inputs": { + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-bq+GcuqqFqgnhRTygMEb5387yYSxzZG+xoOBo1X+i5I=", + "path": "../beam-core", + "type": "path" + }, + "original": { + "path": "../beam-core", + "type": "path" + } + }, + "beam-migrate": { + "inputs": { + "flake-parts": "flake-parts_2", + "haskell-flake": "haskell-flake_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-d5N0AZgGSKFoKh0V5oZK7aByxNvefZGUkpPoA8YU3Xo=", + "path": "../beam-migrate", + "type": "path" + }, + "original": { + "path": "../beam-migrate", + "type": "path" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1768135262, + "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_3" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_2": { + "locked": { + "lastModified": 1769355516, + "narHash": "sha256-HHoaDIz42Yfd4Ll8ik9tYN3Q/77hesaNhD/GZ/ZZzD0=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "692b0799558e361a9029541f0630c91b8dc96744", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_3": { + "locked": { + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_2": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_3": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "root": { + "inputs": { + "beam-core": "beam-core", + "beam-migrate": "beam-migrate", + "flake-parts": "flake-parts_3", + "haskell-flake": "haskell-flake_3", + "nixpkgs": "nixpkgs_3" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/beam-postgres/flake.nix b/beam-postgres/flake.nix new file mode 100644 index 000000000..a4ecf81be --- /dev/null +++ b/beam-postgres/flake.nix @@ -0,0 +1,36 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/89c2b2330e733d6cdb5eae7b899326930c2c0648"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + beam-core.url = "path:../beam-core"; + beam-migrate.url = "path:../beam-migrate"; + }; + + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, ... }: { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.haskell-flake.flakeModule + ]; + perSystem = { self', pkgs, lib, config, ... }: { + haskellProjects.default = { + projectFlakeName = "beam"; + basePackages = pkgs.haskell.packages.ghc98; + autoWire = ["packages" "checks" "devShells" "apps"]; + devShell.tools = hp: { + "haskell-language-server" = null; + }; + packages = { + beam-core.source = inputs.beam-core; + beam-migrate.source = inputs.beam-migrate; + }; + settings = { + pretty-simple = { + check = false; + }; + }; + }; + }; + }); +} diff --git a/beam-sqlite/Database/Beam/Sqlite/Migrate.hs b/beam-sqlite/Database/Beam/Sqlite/Migrate.hs index b0d74d88a..045091622 100644 --- a/beam-sqlite/Database/Beam/Sqlite/Migrate.hs +++ b/beam-sqlite/Database/Beam/Sqlite/Migrate.hs @@ -29,6 +29,7 @@ import Database.Beam.Sqlite.Syntax import Control.Applicative import Control.Exception import Control.Monad.Reader +import Control.Monad (forM, void, guard) import Database.SQLite.Simple (open, close, query_) diff --git a/beam-sqlite/Database/Beam/Sqlite/Syntax.hs b/beam-sqlite/Database/Beam/Sqlite/Syntax.hs index 82bdd74eb..fed09c5e9 100644 --- a/beam-sqlite/Database/Beam/Sqlite/Syntax.hs +++ b/beam-sqlite/Database/Beam/Sqlite/Syntax.hs @@ -45,6 +45,7 @@ module Database.Beam.Sqlite.Syntax ) where import Database.Beam.Backend.SQL +import Database.Beam.Backend.SQL.SQL92 import Database.Beam.Backend.SQL.AST (ExtractField(..)) import Database.Beam.Haskell.Syntax import Database.Beam.Migrate.Checks (HasDataTypeCreatedCheck(..)) @@ -53,6 +54,7 @@ import Database.Beam.Migrate.SQL.SQL92 import Database.Beam.Migrate.Serialization import Database.Beam.Query hiding (ExtractField(..)) + import Data.ByteString (ByteString) import qualified Data.ByteString as B import Data.ByteString.Builder @@ -867,14 +869,16 @@ instance IsSql92AggregationSetQuantifierSyntax SqliteAggregationSetQuantifierSyn setQuantifierDistinct = SqliteAggregationSetQuantifierSyntax (emit "DISTINCT") setQuantifierAll = SqliteAggregationSetQuantifierSyntax (emit "ALL") -instance IsSql92AggregationIndexHintsSyntax SqliteExpressionSyntax where - setIndexForce = error "Not Implemented for sqlite" - setIndexUse = error "Not Implemented for sqlite" +instance IsSql92AggregationIndexHintsSyntax SqliteAggregationSetQuantifierSyntax where + type Sql92AggregationIndexHintsSyntax SqliteAggregationSetQuantifierSyntax = SqliteExpressionSyntax + + setIndexForce = const (SqliteAggregationSetQuantifierSyntax mempty) + setIndexUse = const (SqliteAggregationSetQuantifierSyntax mempty) instance IsSql92InsertSyntax SqliteInsertSyntax where type Sql92InsertTableNameSyntax SqliteInsertSyntax = SqliteTableNameSyntax type Sql92InsertValuesSyntax SqliteInsertSyntax = SqliteInsertValuesSyntax - + insertStmt table fields values = SqliteInsertSyntax table fields values Nothing instance IsSql92InsertValuesSyntax SqliteInsertValuesSyntax where diff --git a/beam-sqlite/beam-sqlite.cabal b/beam-sqlite/beam-sqlite.cabal index 7ac769420..4558eed19 100644 --- a/beam-sqlite/beam-sqlite.cabal +++ b/beam-sqlite/beam-sqlite.cabal @@ -51,7 +51,7 @@ library build-depends: Win32 >=2.4 && <2.8 if os(freebsd) || os(netbsd) || os(openbsd) || os(darwin) || os(linux) || os(solaris) || os(android) cpp-options: -DUNIX - build-depends: unix >=2.0 && <2.8 + build-depends: unix flag werror description: Enable -Werror during development diff --git a/beam-sqlite/flake.lock b/beam-sqlite/flake.lock new file mode 100644 index 000000000..1447d608d --- /dev/null +++ b/beam-sqlite/flake.lock @@ -0,0 +1,323 @@ +{ + "nodes": { + "beam-core": { + "inputs": { + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-u4F8QoNRHbQ5MTSd9VGsI9xu4eT7L+hI1pjrvZ+nqdU=", + "path": "../beam-core", + "type": "path" + }, + "original": { + "path": "../beam-core", + "type": "path" + } + }, + "beam-core_2": { + "inputs": { + "flake-parts": "flake-parts_2", + "haskell-flake": "haskell-flake_2", + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-u4F8QoNRHbQ5MTSd9VGsI9xu4eT7L+hI1pjrvZ+nqdU=", + "path": "../beam-core", + "type": "path" + }, + "original": { + "path": "../beam-core", + "type": "path" + } + }, + "beam-migrate": { + "inputs": { + "beam-core": "beam-core_2", + "flake-parts": "flake-parts_3", + "haskell-flake": "haskell-flake_3", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-MFAZ/HjENEvAJIQaHMiEF/0Pxrn99fax56w3AFPvzgA=", + "path": "../beam-migrate", + "type": "path" + }, + "original": { + "path": "../beam-migrate", + "type": "path" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_2" + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_3" + }, + "locked": { + "lastModified": 1768135262, + "narHash": "sha256-PVvu7OqHBGWN16zSi6tEmPwwHQ4rLPU9Plvs8/1TUBY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "80daad04eddbbf5a4d883996a73f3f542fa437ac", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_4": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_4" + }, + "locked": { + "lastModified": 1767609335, + "narHash": "sha256-feveD98mQpptwrAEggBQKJTYbvwwglSbOv53uCfH9PY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "250481aafeb741edfe23d29195671c19b36b6dca", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "haskell-flake": { + "locked": { + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_2": { + "locked": { + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_3": { + "locked": { + "lastModified": 1769355516, + "narHash": "sha256-HHoaDIz42Yfd4Ll8ik9tYN3Q/77hesaNhD/GZ/ZZzD0=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "692b0799558e361a9029541f0630c91b8dc96744", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "haskell-flake_4": { + "locked": { + "lastModified": 1767640826, + "narHash": "sha256-017M+QPfv4DzB0BYUvoeTmJ9+r6C8cwt3kr88eMu16I=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "70b04dd7cc87d038aa31f911cb4d231c5afa93ee", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "haskell-flake", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_2": { + "locked": { + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_3": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-lib_4": { + "locked": { + "lastModified": 1765674936, + "narHash": "sha256-k00uTP4JNfmejrCLJOwdObYC9jHRrr/5M/a/8L2EIdo=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "2075416fcb47225d9b68ac469a5c4801a9c4dd85", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs_3": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", + "type": "github" + } + }, + "root": { + "inputs": { + "beam-core": "beam-core", + "beam-migrate": "beam-migrate", + "flake-parts": "flake-parts_4", + "haskell-flake": "haskell-flake_4", + "nixpkgs": "nixpkgs_4" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/beam-sqlite/flake.nix b/beam-sqlite/flake.nix new file mode 100644 index 000000000..a4ecf81be --- /dev/null +++ b/beam-sqlite/flake.nix @@ -0,0 +1,36 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/89c2b2330e733d6cdb5eae7b899326930c2c0648"; + flake-parts.url = "github:hercules-ci/flake-parts"; + haskell-flake.url = "github:srid/haskell-flake"; + beam-core.url = "path:../beam-core"; + beam-migrate.url = "path:../beam-migrate"; + }; + + outputs = inputs@{ self, nixpkgs, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, ... }: { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.haskell-flake.flakeModule + ]; + perSystem = { self', pkgs, lib, config, ... }: { + haskellProjects.default = { + projectFlakeName = "beam"; + basePackages = pkgs.haskell.packages.ghc98; + autoWire = ["packages" "checks" "devShells" "apps"]; + devShell.tools = hp: { + "haskell-language-server" = null; + }; + packages = { + beam-core.source = inputs.beam-core; + beam-migrate.source = inputs.beam-migrate; + }; + settings = { + pretty-simple = { + check = false; + }; + }; + }; + }; + }); +} diff --git a/cabal.project b/cabal.project deleted file mode 100644 index 43f47cd7a..000000000 --- a/cabal.project +++ /dev/null @@ -1,6 +0,0 @@ -packages: - beam-core - beam-migrate - beam-migrate-cli - beam-postgres - beam-sqlite diff --git a/flake.lock b/flake.lock index 591b775b5..121f50fac 100644 --- a/flake.lock +++ b/flake.lock @@ -1,94 +1,75 @@ { "nodes": { - "euler-build": { + "flake-parts": { "inputs": { - "flake-utils": "flake-utils", - "nix-inclusive": "nix-inclusive", - "nixpkgs": "nixpkgs" + "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1618838162, - "narHash": "sha256-MjEvoyBUPRY5xrbUmAhvismwrK4nIYy3jf2g81ijJsU=", - "ref": "master", - "rev": "90f393f7f91e1bb9d7b3c0ece1aa919797d1987b", - "revCount": 33, - "type": "git", - "url": "ssh://git@ssh.bitbucket.juspay.net/jbiz/euler-build" - }, - "original": { - "id": "euler-build", - "type": "indirect" - } - }, - "flake-utils": { - "locked": { - "lastModified": 1600209923, - "narHash": "sha256-zoOWauTliFEjI++esk6Jzk7QO5EKpddWXQm9yQK24iM=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "3cd06d3c1df6879c9e41cb2c33113df10566c760", + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hercules-ci", + "repo": "flake-parts", "type": "github" } }, - "nix-inclusive": { - "inputs": { - "stdlib": "stdlib" - }, + "haskell-flake": { "locked": { - "lastModified": 1604413592, - "narHash": "sha256-3cr2RRBCXNb+6Q1s3tEQiN4LjoFC8OsMSG8WuCyGe/g=", - "owner": "juspay", - "repo": "nix-inclusive", - "rev": "2ca1706029bfcf4bb7eaf17b4f32e49f436a148e", + "lastModified": 1769989003, + "narHash": "sha256-Z7cC5jPmLYrEEzE+WNU/NIgwCLa5P4W5b9uXzx+HwkM=", + "owner": "srid", + "repo": "haskell-flake", + "rev": "d5c7dfaa97dbb446a615923ad7e4d9efabe73c52", "type": "github" }, "original": { - "owner": "juspay", - "repo": "nix-inclusive", - "rev": "2ca1706029bfcf4bb7eaf17b4f32e49f436a148e", + "owner": "srid", + "repo": "haskell-flake", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1618072958, - "narHash": "sha256-QDKj58ECixtb4EJMWV5D5Lb2xdCgab1Opi4zjQWbDOg=", - "owner": "NixOS", + "lastModified": 1763421233, + "narHash": "sha256-Stk9ZYRkGrnnpyJ4eqt9eQtdFWRRIvMxpNRf4sIegnw=", + "owner": "nixos", "repo": "nixpkgs", - "rev": "a73020b2a150322c9832b50baeb0296ba3b13dd7", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", "type": "github" }, "original": { - "owner": "NixOS", + "owner": "nixos", "repo": "nixpkgs", - "rev": "a73020b2a150322c9832b50baeb0296ba3b13dd7", + "rev": "89c2b2330e733d6cdb5eae7b899326930c2c0648", "type": "github" } }, - "root": { - "inputs": { - "euler-build": "euler-build" - } - }, - "stdlib": { + "nixpkgs-lib": { "locked": { - "lastModified": 1590026685, - "narHash": "sha256-E5INrVvYX/P/UpcoUFDAsuHem+lsqT+/teBs9O7oc9Q=", - "owner": "manveru", - "repo": "nix-lib", - "rev": "99088cf7febcdb21afd375a335dcafa959bef3ed", + "lastModified": 1769909678, + "narHash": "sha256-cBEymOf4/o3FD5AZnzC3J9hLbiZ+QDT/KDuyHXVJOpM=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "72716169fe93074c333e8d0173151350670b824c", "type": "github" }, "original": { - "owner": "manveru", - "repo": "nix-lib", + "owner": "nix-community", + "repo": "nixpkgs.lib", "type": "github" } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "haskell-flake": "haskell-flake", + "nixpkgs": "nixpkgs" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index e777b57bf..2840bd908 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,6 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + nixpkgs.url = "github:nixos/nixpkgs/89c2b2330e733d6cdb5eae7b899326930c2c0648"; flake-parts.url = "github:hercules-ci/flake-parts"; haskell-flake.url = "github:srid/haskell-flake"; }; @@ -14,8 +14,18 @@ perSystem = { self', pkgs, lib, config, ... }: { haskellProjects.default = { projectFlakeName = "beam"; - basePackages = pkgs.haskell.packages.ghc927; + basePackages = pkgs.haskell.packages.ghc98; autoWire = ["packages" "checks" "devShells" "apps"]; + devShell.tools = hp: { + "haskell-language-server" = null; + }; + packages = { + beam-core.source = ./beam-core; + beam-migrate.source = ./beam-migrate; + beam-migrate-cli.source = ./beam-migrate-cli; + beam-postgres.source = ./beam-postgres; + beam-sqlite.source = ./beam-sqlite; + }; settings = { pretty-simple = { check = false; @@ -24,4 +34,4 @@ }; }; }); -} +}