From ea538ae81d965817c791a34e2221b82a61b3f1f6 Mon Sep 17 00:00:00 2001 From: Jacek Galowicz Date: Mon, 27 Sep 2021 13:21:00 +0200 Subject: [PATCH] Fix wrong postgres type for SqlInt64 Solution taken from #75 Author: kaldonir Date: Wed Jun 2 17:17:39 2021 +0200 --- src/Database/Persist/Migration/Postgres.hs | 7 ++++--- .../postgresql/migration-with-shorter-path.txt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Database/Persist/Migration/Postgres.hs b/src/Database/Persist/Migration/Postgres.hs index d319946..68b0f80 100644 --- a/src/Database/Persist/Migration/Postgres.hs +++ b/src/Database/Persist/Migration/Postgres.hs @@ -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 diff --git a/test/goldens-unit/postgresql/migration-with-shorter-path.txt b/test/goldens-unit/postgresql/migration-with-shorter-path.txt index 691fc38..8512577 100644 --- a/test/goldens-unit/postgresql/migration-with-shorter-path.txt +++ b/test/goldens-unit/postgresql/migration-with-shorter-path.txt @@ -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" ) ) []