Skip to content

Commit

Permalink
Merge pull request #79 from tfc/int-patch
Browse files Browse the repository at this point in the history
Fix wrong postgres type for SqlInt64
  • Loading branch information
brandonchinn178 authored Sep 27, 2021
2 parents 66f1312 + 7f68e9b commit dd25379
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Database/Persist/Migration/Postgres.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,10 @@ showColumn Column{..} = concatSql
(\sqls -> Text.unwords $ [quote colName, sqlType] ++ sqls)
$ map showColumnProp colProps
where
sqlType = if AutoIncrement `elem` colProps
then "SERIAL"
else showSqlType colType
sqlType = case (AutoIncrement `elem` colProps, colType) of
(True, SqlInt32) -> "SERIAL"
(True, SqlInt64) -> "BIGSERIAL"
_ -> showSqlType colType

-- | Show a 'SqlType'. See `showSqlType` from `Database.Persist.Postgresql`.
showSqlType :: SqlType -> Text
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CREATE TABLE IF NOT EXISTS "person" ( "id" SERIAL NOT NULL ,"gender" VARCHAR,PRIMARY KEY ( "id" ) )
CREATE TABLE IF NOT EXISTS "person" ( "id" BIGSERIAL NOT NULL ,"gender" VARCHAR,PRIMARY KEY ( "id" ) )

[]
2 changes: 2 additions & 0 deletions test/integration/Migration.hs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
Expand Down

0 comments on commit dd25379

Please sign in to comment.