在创建表时,gorm 不支持设置 autoIncrement 标志?

问题描述

我想创建一个这样的表:

p.db.Table(vocabTbl).Set("gorm:table_options","ENGINE=InnoDB").CreateTable(&entity.VocabTemplate{})

entity.VocabTemplate{} 的 ID 号如下:

type VocabTemplate struct {
ID          int    `gorm:"primary_key;column:id;type:int(11);not null; AUTO_INCREMENT" json:"id"`

无论我设置标志“AUTO_INCREMENT”还是“autoIncrement”,似乎这个标志都不起作用。

(/data/proj/ugc-text-op-cgi/internal/repository/repo/quat_repo.go:14) [2021-04-28 16:37:31] [45.53ms] 创建表 vocab.vocab_1_55555_1_1 (id int(11) NOT NULL,words varchar(120) ) NOT NULL,language int(11) NOT NULL,state int(11) NOT NULL,evil_type int(11) NOT NULL,match_bitmap bigint NOT NULL,{ {1}} varchar(120) NOT NULL,operator varchar(120) NOT NULL,add_reason datetime NOT NULL,PRIMARY KEY (add_date)) ENGINE=InnoDB
[0 行受影响或返回]

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)