Skip to content

struct AutoMigrate does not create multi primary key #148

@onewesong

Description

@onewesong

Test v1.9.0 is normal
image
Test v1.10.0 only create one pk: id
image
Below is the test code:

package main

import (
	"testing"

	"github.com/glebarez/sqlite"
	"gorm.io/gorm"
)

type MixConfig struct {
	ID     int    `gorm:"column:id;primaryKey;not null"`
	Device string `gorm:"column:device;type:varchar(32);primaryKey;not null"`
}

func TestCreate(t *testing.T) {
	db, err := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})
	if err != nil {
		panic("failed to connect database")
	}
	db = db.Debug()
	err = db.AutoMigrate(&MixConfig{})
	if err != nil {
		panic("failed to migrate database")
	}
}

I think it's relate to this pr: go-gorm#167

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions