beam-migrate 0.5.3.0 → 0.5.3.1
raw patch · 3 files changed
+28/−11 lines, 3 filesdep ~hashabledep ~timePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: hashable, time
API changes (from Hackage documentation)
- Database.Beam.Migrate.SQL.Tables: instance Data.String.IsString Database.Beam.Migrate.SQL.Tables.DatabaseSchema
+ Database.Beam.Migrate.SQL.Tables: data DatabaseSchema
Files
- ChangeLog.md +6/−0
- Database/Beam/Migrate/SQL/Tables.hs +21/−10
- beam-migrate.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,9 @@+# 0.5.3.1++## Bug fixes++* Removed the `IsString` instance for `DatabaseSchema`, which allowed for the use of database schemas that did not exist.+ # 0.5.3.0 ## Added features
Database/Beam/Migrate/SQL/Tables.hs view
@@ -21,7 +21,7 @@ , addColumn, dropColumn -- * Schema manipulation- , createDatabaseSchema, dropDatabaseSchema, existingDatabaseSchema+ , DatabaseSchema(databaseSchemaName), createDatabaseSchema, dropDatabaseSchema, existingDatabaseSchema -- * Field specification , DefaultValue, Constraint(..), NotNullConstraint@@ -55,7 +55,6 @@ import Data.Coerce (coerce) import Data.Kind (Type)-import Data.String (IsString) import Data.Text (Text) import Data.Typeable import qualified Data.Kind as Kind (Constraint)@@ -82,10 +81,11 @@ -- * Schema manipulation --- | Represents a database schema. To create one, see 'createDatabaseSchema'.+-- | Represents a database schema. To create one, see 'createDatabaseSchema'; +-- to materialize one, see 'existingDatabaseSchema'. newtype DatabaseSchema - = MkDatabaseSchema Text- deriving (Eq, Show, IsString)+ = DatabaseSchema{databaseSchemaName :: Text}+ deriving (Eq, Show) -- | Add a @CREATE SCHEMA@ statement to this migration --@@ -97,7 +97,7 @@ -> Migration be DatabaseSchema createDatabaseSchema nm = do upDown (createSchemaCmd (createSchemaSyntax (schemaName nm))) Nothing- pure $ MkDatabaseSchema nm+ pure $ DatabaseSchema nm -- | Add a @DROP SCHEMA@ statement to this migration. --@@ -108,12 +108,23 @@ dropDatabaseSchema :: BeamMigrateSchemaSqlBackend be => DatabaseSchema -> Migration be ()-dropDatabaseSchema (MkDatabaseSchema nm) +dropDatabaseSchema (DatabaseSchema nm) = upDown (dropSchemaCmd (dropSchemaSyntax (schemaName nm))) Nothing --- | Materialize a schema for use during a migration (for example, to drop it).+-- | Materialize a schema for use during a migration.+--+-- Example usage, where @NewDB@ has one more table than @OldDB@ in the @my_schema@ schema:+--+-- @+-- migrationStep :: 'CheckedDatabaseSettings' be OldDB+-- -> 'Migration' be ('CheckedDatabaseSettings' be NewDB)+-- migrationStep (OldDB oldtable)= do+-- schema <- 'existingDatabaseSchema' "my_schema"+-- pure $ NewDb <$> pure oldtable+-- <*> 'createTableWithSchema' (Just schema) "my_table"+-- @ existingDatabaseSchema :: Text -> Migration be DatabaseSchema-existingDatabaseSchema = pure . MkDatabaseSchema+existingDatabaseSchema = pure . DatabaseSchema -- | Add a @CREATE TABLE@ statement to this migration, with an explicit schema --@@ -155,7 +166,7 @@ schemaCheck = case maybeSchemaName of Nothing -> []- Just (MkDatabaseSchema sn) -> [ SomeDatabasePredicate (SchemaExistsPredicate sn) ] + Just (DatabaseSchema sn) -> [ SomeDatabasePredicate (SchemaExistsPredicate sn) ] upDown command Nothing pure (CheckedDatabaseEntity
beam-migrate.cabal view
@@ -1,5 +1,5 @@ name: beam-migrate-version: 0.5.3.0+version: 0.5.3.1 synopsis: SQL DDL support and migrations support library for Beam description: This package provides type classes to allow backends to implement SQL DDL support for beam. This allows you to use beam syntax to