Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e7011af

Browse files
Merge pull request vapor#33 from vapor/postgres-9-serial-primary-keys
Fix the integer width of serial primary keys for 2- and 8-bit integers for Postgres 9
2 parents b1ac551 + ecc7c26 commit e7011af

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("unexpected primary key type \(field.type.type) in branch that should only handle int2/int4/int8")
31+
}
2732
}
2833
default: string += " PRIMARY KEY"
2934
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /