Skip to content

Commit

Permalink
fix type signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbecich committed Dec 8, 2024
1 parent be0b014 commit 211b467
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
4 changes: 2 additions & 2 deletions beam-postgres/examples/src/Pagila/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import Control.Arrow ( (>>>) )
import Database.Beam (DatabaseSettings)
import Database.Beam.Migrate.Types ( CheckedDatabaseSettings, MigrationSteps, unCheckDatabase
, evaluateDatabase, migrationStep)
import Database.Beam.Postgres (Postgres, PgCommandSyntax)
import Database.Beam.Postgres (Postgres)

-- migration :: MigrationSteps PgCommandSyntax () (CheckedDatabaseSettings Postgres Pagila.Schema.V0002.PagilaDb)
migration :: MigrationSteps Postgres () (CheckedDatabaseSettings Postgres Pagila.Schema.V0002.PagilaDb)
migration = migrationStep "Initial commit" V0001.migration >>>
migrationStep "Add film actor, inventory, rental table" V0002.migration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ import Database.Beam
import Database.Beam.Postgres
( smallserial,
now_,
PgCommandSyntax,
Postgres,
ResultError(ConversionFailed) )
import Database.Beam.Postgres.Syntax
( pgTextType, PgColumnSchemaSyntax, PgDataTypeSyntax )
( pgTextType )
import Database.Beam.Migrate
( createTable,
defaultTo_,
Expand Down Expand Up @@ -132,7 +131,7 @@ instance Beamable AddressT
lastUpdateField :: TableFieldSchema Postgres LocalTime
lastUpdateField = field "last_update" timestamp (defaultTo_ now_) notNull

-- migration :: () -> Migration PgCommandSyntax (CheckedDatabaseSettings Postgres PagilaDb)
migration :: () -> Migration Postgres (CheckedDatabaseSettings Postgres PagilaDb)
migration () = do
-- year_ <- createDomain "year" integer (check (\yr -> yr >=. 1901 &&. yr <=. 2155))
PagilaDb <$> createTable "address"
Expand Down
7 changes: 2 additions & 5 deletions beam-postgres/examples/src/Pagila/Schema/V0001.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,18 @@ import Database.Beam
maybeType,
smallint,
boolean,
date,
numeric,
char,
binaryLargeObject )
import Database.Beam.Postgres
( Postgres,
PgCommandSyntax,
now_,
serial,
smallserial,
text,
bytea )
import Database.Beam.Postgres.Syntax (PgColumnSchemaSyntax)
import Database.Beam.Migrate.Types
( CheckedDatabaseSettings, Migration )
( CheckedDatabaseEntity, Migration )
import Database.Beam.Migrate.SQL
( TableFieldSchema,
field,
Expand Down Expand Up @@ -332,7 +329,7 @@ createDateField = field "create_date" timestamp (defaultTo_ now_) notNull
lastUpdateField :: TableFieldSchema Postgres LocalTime
lastUpdateField = field "last_update" timestamp (defaultTo_ now_) notNull

-- migration :: () -> Migration PgCommandSyntax (CheckedDatabaseSettings Postgres PagilaDb)
migration :: () -> Migration Postgres (PagilaDb (CheckedDatabaseEntity Postgres db0))
migration () = do
-- year_ <- createDomain "year" integer (check (\yr -> yr >=. 1901 &&. yr <=. 2155))
PagilaDb <$> createTable "actor"
Expand Down
12 changes: 3 additions & 9 deletions beam-postgres/examples/src/Pagila/Schema/V0002.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@ import Database.Beam
TableEntity,
Database,
smallint )
import Database.Beam.Postgres ( Postgres, PgCommandSyntax )
import Database.Beam.Postgres ( Postgres )
import Database.Beam.Migrate.Types
( CheckedDatabaseSettings, Migration )
import Database.Beam.Migrate.SQL.Tables
( field, notNull, createTable, preserve )

import qualified Database.PostgreSQL.Simple as Pg

import Data.Text (Text)
import Data.ByteString (ByteString)
import qualified Data.ByteString.Lazy as BL
import Data.Time.LocalTime (LocalTime)
import Data.Scientific (Scientific)

-- film actor

Expand Down Expand Up @@ -82,8 +76,8 @@ data PagilaDb f
} deriving Generic
instance Database Postgres PagilaDb

-- migration :: CheckedDatabaseSettings Postgres V0001.PagilaDb
-- -> Migration PgCommandSyntax (CheckedDatabaseSettings Postgres PagilaDb)
migration :: CheckedDatabaseSettings Postgres V0001.PagilaDb
-> Migration Postgres (CheckedDatabaseSettings Postgres PagilaDb)
migration oldDb =
PagilaDb
<$> preserve (V0001.actor oldDb)
Expand Down

0 comments on commit 211b467

Please sign in to comment.