Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Commit

Permalink
Fix wrong postgres type for SqlInt64
Browse files Browse the repository at this point in the history
Solution taken from brandonchinn178#75

Author:    kaldonir <mnapi@gmx.de>
Date:      Wed Jun 2 17:17:39 2021 +0200
  • Loading branch information
Jacek Galowicz committed Sep 27, 2021
1 parent 037679e commit ea538ae
Show file tree
Hide file tree
Showing 2 changed files with 5 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" ) )

[]

0 comments on commit ea538ae

Please sign in to comment.