Skip to content

Commit d937466

Browse files
committed
Fix the integer width of serial primary keys for 2- and 8-bit integers for Postgres 9.
See https://www.postgresql.org/docs/current/static/datatype-numeric.html.
1 parent 9851c69 commit d937466

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sources/FluentPostgreSQL/PostgreSQLDatabase+SchemaSupporting.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ extension PostgreSQLDatabase: SchemaSupporting, IndexSupporting {
2323
string += " GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY"
2424
} else {
2525
// not appending!
26-
string = "SERIAL PRIMARY KEY"
26+
switch field.type.type {
27+
case .int2: string = "SMALLSERIAL PRIMARY KEY"
28+
case .int4: string = "SERIAL PRIMARY KEY"
29+
case .int8: string = "BIGSERIAL PRIMARY KEY"
30+
default: fatalError("should be unreachable")
31+
}
2732
}
2833
default: string += " PRIMARY KEY"
2934
}

0 commit comments

Comments
 (0)