diff --git a/beam-postgres/examples/pagila.cabal b/beam-postgres/examples/pagila.cabal index a0f939f1..62092eee 100644 --- a/beam-postgres/examples/pagila.cabal +++ b/beam-postgres/examples/pagila.cabal @@ -19,7 +19,7 @@ library Pagila.Schema.V0001, Pagila.Schema.V0002, Pagila.Schema.CustomMigrateExample, - Pagila.Test + Pagila.CompileTimeTest -- other-modules: -- other-extensions: build-depends: base, diff --git a/beam-postgres/examples/src/Pagila/Test.hs b/beam-postgres/examples/src/Pagila/CompileTimeTest.hs similarity index 80% rename from beam-postgres/examples/src/Pagila/Test.hs rename to beam-postgres/examples/src/Pagila/CompileTimeTest.hs index f5da59cc..e8bb0243 100644 --- a/beam-postgres/examples/src/Pagila/Test.hs +++ b/beam-postgres/examples/src/Pagila/CompileTimeTest.hs @@ -6,21 +6,20 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DeriveGeneric #-} -module Pagila.Test where - -import Control.Arrow () +module Pagila.CompileTimeTest where import Data.Int ( Int32 ) import Data.Text(Text) import Database.Beam ( Generic, Beamable, Columnar, Database, Table(..), TableEntity ) -import Database.Beam.Postgres -import Database.Beam.Backend.Types () +import Database.Beam.Postgres ( Postgres ) import Database.Beam.Migrate.Generics -import Database.Beam.Migrate.SQL.SQL92 -import Database.Beam.Migrate.Types hiding (migrateScript) + ( defaultMigratableDbSettings ) +import Database.Beam.Migrate.SQL.SQL92 ( IsSql92DdlCommandSyntax ) +import Database.Beam.Migrate.Types ( CheckedDatabaseSettings ) +-- compile-time test data SimpleTbl f = SimpleTbl { simpletblField1 :: Columnar f Int32 diff --git a/beam-postgres/examples/src/Pagila/Schema/CustomMigrateExample.hs b/beam-postgres/examples/src/Pagila/Schema/CustomMigrateExample.hs index 4efc1413..8cad7c5f 100644 --- a/beam-postgres/examples/src/Pagila/Schema/CustomMigrateExample.hs +++ b/beam-postgres/examples/src/Pagila/Schema/CustomMigrateExample.hs @@ -127,13 +127,12 @@ instance Database Postgres PagilaDb instance Beamable (PrimaryKey AddressT) instance Beamable AddressT --- lastUpdateField :: TableFieldSchema PgColumnSchemaSyntax LocalTime lastUpdateField :: TableFieldSchema Postgres LocalTime lastUpdateField = field "last_update" timestamp (defaultTo_ now_) notNull migration :: () -> Migration Postgres (CheckedDatabaseSettings Postgres PagilaDb) migration () = do --- year_ <- createDomain "year" integer (check (\yr -> yr >=. 1901 &&. yr <=. 2155)) + -- year_ <- createDomain "year" integer (check (\yr -> yr >=. 1901 &&. yr <=. 2155)) PagilaDb <$> createTable "address" (AddressT (field "address_id" smallserial) diff --git a/beam-postgres/examples/src/Pagila/Schema/V0001.hs b/beam-postgres/examples/src/Pagila/Schema/V0001.hs index d17f08d8..666644c0 100644 --- a/beam-postgres/examples/src/Pagila/Schema/V0001.hs +++ b/beam-postgres/examples/src/Pagila/Schema/V0001.hs @@ -9,6 +9,15 @@ {-# LANGUAGE DeriveGeneric #-} module Pagila.Schema.V0001 where +-- TODO explicit module exports +-- ( FilmT(..), ActorT(..), AddressT, CityT, CountryT, CategoryT, CustomerT +-- , FilmCategoryT, LanguageT, StoreT, StaffT, PagilaDb, ActorId +-- , PrimaryKey(..) +-- , actor, address, city, country, category, customer +-- , film, filmCategory, language, store, staff +-- , lastUpdateField +-- ) +-- where import Database.Beam ( Generic, @@ -235,14 +244,16 @@ data FilmT f , filmLastUpdate :: Columnar f LocalTime } deriving Generic type Film = FilmT Identity -deriving instance Eq Film; deriving instance Show Film +deriving instance Eq Film +deriving instance Show Film instance Table FilmT where data PrimaryKey FilmT f = FilmId (Columnar f (SqlSerial Int32)) deriving Generic primaryKey = FilmId . filmId type FilmId = PrimaryKey FilmT Identity -deriving instance Eq FilmId; deriving instance Show FilmId +deriving instance Eq FilmId +deriving instance Show FilmId -- Film category diff --git a/beam-postgres/examples/src/Pagila/Schema/V0002.hs b/beam-postgres/examples/src/Pagila/Schema/V0002.hs index a85ba691..48cf37a4 100644 --- a/beam-postgres/examples/src/Pagila/Schema/V0002.hs +++ b/beam-postgres/examples/src/Pagila/Schema/V0002.hs @@ -12,7 +12,6 @@ module Pagila.Schema.V0002 ( module V0001' , FilmActorT(..), FilmActor , PrimaryKey(..), FilmActorId - , migration, PagilaDb ) where