Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change kallax.NumericID as PK from serial to bigserial #266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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