-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Closed
Labels
type:missing reproduction stepsmissing reproduction stepsmissing reproduction steps
Description
Description
Very simple use case:
package main
import (
"log"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
type User struct {
ID int64 `gorm:"primaryKey;autoIncrement;not null"`
Name string `gorm:"unique;not null"`
Mail string `gorm:"unique;not null"`
Pass string `gorm:"unique;not null"`
}
func main() {
con, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
if err != nil {
log.Panic(err)
}
con.AutoMigrate(User{})
}
The database and table is created. Everything else is fine. Except AUTOINCREMENT
is not enabled on primary key. What am I doing wrong here? (I have not tried with other drivers) (just tried on mysql and works fine there)
This is the DDL of the generated table:
CREATE TABLE users (
id INTEGER NOT NULL,
name TEXT NOT NULL
UNIQUE,
mail TEXT NOT NULL
UNIQUE,
pass TEXT NOT NULL
UNIQUE,
PRIMARY KEY (
id
)
);
OS: Windows x64
GO: 1.17.2 (fresh installation. just began learning go)
Metadata
Metadata
Assignees
Labels
type:missing reproduction stepsmissing reproduction stepsmissing reproduction steps