Skip to content

Commit

Permalink
Change kallax.NumericID as PK from serial to bigserial
Browse files Browse the repository at this point in the history
Signed-off-by: Abdülhamit Yilmaz <mr.yilmaz@gmx.de>
  • Loading branch information
abduelhamit committed Apr 26, 2018
1 parent 6e31900 commit 46fdceb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -707,8 +707,8 @@ kallax migrate up --dir ./my-migrations --dsn 'user:pass@localhost:5432/dbname?s
| --- | --- |
| `kallax.ULID` | `uuid` |
| `kallax.UUID` | `uuid` |
| `kallax.NumericID` | `serial` on primary keys, `bigint` on foreign keys |
| `int64` on primary keys | `serial` |
| `kallax.NumericID` | `bigserial` on primary keys, `bigint` on foreign keys |
| `int64` on primary keys | `bigserial` |
| `int64` on foreign keys and other fields| `bigint` |
| `string` | `text` |
| `rune` | `char(1)` |
Expand Down
2 changes: 1 addition & 1 deletion generator/migration.go
Expand Up @@ -1014,7 +1014,7 @@ var typeMappings = map[string]ColumnType{
var idTypeMappings = map[string]ColumnType{
"kallax.ULID": UUIDColumn,
"kallax.UUID": UUIDColumn,
"kallax.NumericID": SerialColumn,
"kallax.NumericID": BigSerialColumn,
}

func reverse(slice []string) []string {
Expand Down
6 changes: 3 additions & 3 deletions generator/migration_test.go
Expand Up @@ -602,7 +602,7 @@ type Profile struct {
type ProfileMetadata struct {
kallax.Model ` + "`table:\"metadata\"`" + `
// it's an pk, should be serial
// it's an pk, should be bigserial
ID int64 ` + "`pk:\"autoincr\"`" + `
// a json field
Metadata map[string]interface{}
Expand Down Expand Up @@ -635,7 +635,7 @@ func (s *PackageTransformerSuite) TestTransform() {
expected := mkSchema(
mkTable(
"profiles",
mkCol("id", SerialColumn, true, true, nil),
mkCol("id", BigSerialColumn, true, true, nil),
mkCol("color", ColumnType("char(6)"), false, true, nil),
mkCol("background", TextColumn, false, true, nil),
mkCol("user_id", UUIDColumn, false, false, mkRef("users", "id", true)),
Expand All @@ -644,7 +644,7 @@ func (s *PackageTransformerSuite) TestTransform() {
),
mkTable(
"metadata",
mkCol("id", SerialColumn, true, true, nil),
mkCol("id", BigSerialColumn, true, true, nil),
mkCol("metadata", JSONBColumn, false, true, nil),
mkCol("profile_id", BigIntColumn, false, true, mkRef("profiles", "id", false)),
),
Expand Down

0 comments on commit 46fdceb

Please sign in to comment.