diff --git a/beam-postgres/examples/src/Pagila/Schema.hs b/beam-postgres/examples/src/Pagila/Schema.hs index 233e3948..07fde2e5 100644 --- a/beam-postgres/examples/src/Pagila/Schema.hs +++ b/beam-postgres/examples/src/Pagila/Schema.hs @@ -15,7 +15,7 @@ import Database.Beam.Migrate.Types ( CheckedDatabaseSettings, MigrationSteps, un , evaluateDatabase, migrationStep) import Database.Beam.Postgres (Postgres, PgCommandSyntax) -migration :: MigrationSteps PgCommandSyntax () (CheckedDatabaseSettings Postgres Pagila.Schema.V0002.PagilaDb) +-- migration :: MigrationSteps PgCommandSyntax () (CheckedDatabaseSettings Postgres Pagila.Schema.V0002.PagilaDb) migration = migrationStep "Initial commit" V0001.migration >>> migrationStep "Add film actor, inventory, rental table" V0002.migration diff --git a/beam-postgres/examples/src/Pagila/Schema/CustomMigrateExample.hs b/beam-postgres/examples/src/Pagila/Schema/CustomMigrateExample.hs index 023d2126..27e82e0b 100644 --- a/beam-postgres/examples/src/Pagila/Schema/CustomMigrateExample.hs +++ b/beam-postgres/examples/src/Pagila/Schema/CustomMigrateExample.hs @@ -87,7 +87,7 @@ instance (BeamSqlBackend be, FromBackendRow be T.Text) => FromBackendRow be Ship -- In this case, we want to store it as the postgres type ``text`` -- Look into the module Database.Beam.Postgres.Syntax for a list of other -- postgres types that your custom type can take -shippingCarrierType :: DataType PgDataTypeSyntax ShippingCarrier +shippingCarrierType :: DataType Postgres a shippingCarrierType = DataType pgTextType @@ -128,10 +128,11 @@ instance Database Postgres PagilaDb instance Beamable (PrimaryKey AddressT) instance Beamable AddressT -lastUpdateField :: TableFieldSchema PgColumnSchemaSyntax LocalTime -lastUpdateField = field "last_update" timestamp (defaultTo_ now_) notNull +-- lastUpdateField :: TableFieldSchema PgColumnSchemaSyntax LocalTime +lastUpdateField :: TableFieldSchema Postgres LocalTime +lastUpdateField = field "last_update" timestamp (defaultTo_ now_) notNull -migration :: () -> Migration PgCommandSyntax (CheckedDatabaseSettings Postgres PagilaDb) +-- migration :: () -> Migration PgCommandSyntax (CheckedDatabaseSettings Postgres PagilaDb) migration () = do -- year_ <- createDomain "year" integer (check (\yr -> yr >=. 1901 &&. yr <=. 2155)) PagilaDb <$> createTable "address" diff --git a/beam-postgres/examples/src/Pagila/Schema/V0001.hs b/beam-postgres/examples/src/Pagila/Schema/V0001.hs index 64b319ae..c75f36cd 100644 --- a/beam-postgres/examples/src/Pagila/Schema/V0001.hs +++ b/beam-postgres/examples/src/Pagila/Schema/V0001.hs @@ -207,7 +207,7 @@ data StaffT f , staffStore :: PrimaryKey StoreT f , staffActive :: Columnar f Bool , staffUsername :: Columnar f Text - , staffPassword :: Columnar f ByteString + , staffPassword :: Columnar f Text -- TODO use ByteString , staffLastUpdate :: Columnar f LocalTime , staffPicture :: Columnar f (Maybe ByteString) } deriving Generic @@ -326,10 +326,13 @@ instance Beamable FilmCategoryT instance Beamable (PrimaryKey LanguageT) instance Beamable LanguageT -lastUpdateField :: TableFieldSchema PgColumnSchemaSyntax LocalTime +createDateField :: TableFieldSchema Postgres LocalTime +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 PgCommandSyntax (CheckedDatabaseSettings Postgres PagilaDb) migration () = do -- year_ <- createDomain "year" integer (check (\yr -> yr >=. 1901 &&. yr <=. 2155)) PagilaDb <$> createTable "actor" @@ -366,8 +369,9 @@ migration () = do (field "email" (varchar (Just 50))) (AddressId (field "address_id" serial notNull)) (field "activebool" boolean (defaultTo_ (val_ True)) notNull) - (field "create_date" date (defaultTo_ now_) notNull) - lastUpdateField) + createDateField + lastUpdateField + ) <*> createTable "film" (FilmT (field "film_id" smallserial) (field "title" (varchar (Just 255)) notNull) diff --git a/beam-postgres/examples/src/Pagila/Schema/V0002.hs b/beam-postgres/examples/src/Pagila/Schema/V0002.hs index f2ccb389..9fdd2081 100644 --- a/beam-postgres/examples/src/Pagila/Schema/V0002.hs +++ b/beam-postgres/examples/src/Pagila/Schema/V0002.hs @@ -82,8 +82,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 PgCommandSyntax (CheckedDatabaseSettings Postgres PagilaDb) migration oldDb = PagilaDb <$> preserve (V0001.actor oldDb)