Skip to content

Commit 46fdceb

Browse files
committed
Change kallax.NumericID as PK from serial to bigserial
Signed-off-by: Abdülhamit Yilmaz <[email protected]>
1 parent 6e31900 commit 46fdceb

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ kallax migrate up --dir ./my-migrations --dsn 'user:pass@localhost:5432/dbname?s
707707
| --- | --- |
708708
| `kallax.ULID` | `uuid` |
709709
| `kallax.UUID` | `uuid` |
710-
| `kallax.NumericID` | `serial` on primary keys, `bigint` on foreign keys |
711-
| `int64` on primary keys | `serial` |
710+
| `kallax.NumericID` | `bigserial` on primary keys, `bigint` on foreign keys |
711+
| `int64` on primary keys | `bigserial` |
712712
| `int64` on foreign keys and other fields| `bigint` |
713713
| `string` | `text` |
714714
| `rune` | `char(1)` |

generator/migration.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ var typeMappings = map[string]ColumnType{
10141014
var idTypeMappings = map[string]ColumnType{
10151015
"kallax.ULID": UUIDColumn,
10161016
"kallax.UUID": UUIDColumn,
1017-
"kallax.NumericID": SerialColumn,
1017+
"kallax.NumericID": BigSerialColumn,
10181018
}
10191019

10201020
func reverse(slice []string) []string {

generator/migration_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ type Profile struct {
602602
603603
type ProfileMetadata struct {
604604
kallax.Model ` + "`table:\"metadata\"`" + `
605-
// it's an pk, should be serial
605+
// it's an pk, should be bigserial
606606
ID int64 ` + "`pk:\"autoincr\"`" + `
607607
// a json field
608608
Metadata map[string]interface{}
@@ -635,7 +635,7 @@ func (s *PackageTransformerSuite) TestTransform() {
635635
expected := mkSchema(
636636
mkTable(
637637
"profiles",
638-
mkCol("id", SerialColumn, true, true, nil),
638+
mkCol("id", BigSerialColumn, true, true, nil),
639639
mkCol("color", ColumnType("char(6)"), false, true, nil),
640640
mkCol("background", TextColumn, false, true, nil),
641641
mkCol("user_id", UUIDColumn, false, false, mkRef("users", "id", true)),
@@ -644,7 +644,7 @@ func (s *PackageTransformerSuite) TestTransform() {
644644
),
645645
mkTable(
646646
"metadata",
647-
mkCol("id", SerialColumn, true, true, nil),
647+
mkCol("id", BigSerialColumn, true, true, nil),
648648
mkCol("metadata", JSONBColumn, false, true, nil),
649649
mkCol("profile_id", BigIntColumn, false, true, mkRef("profiles", "id", false)),
650650
),

0 commit comments

Comments
 (0)