增加自动迁移数据表代码

This commit is contained in:
RockYang
2025-04-29 22:55:30 +08:00
parent d1c9fd6eba
commit 8a2d2f66b5
89 changed files with 484 additions and 406 deletions

View File

@@ -1,14 +1,24 @@
package model
import (
"time"
)
type ChatRole struct {
BaseModel
Tid int
Key string `gorm:"column:marker;unique"` // 角色唯一标识
Name string // 角色名称
Context string `gorm:"column:context_json"` // 角色语料信息 json
HelloMsg string // 打招呼的消息
Icon string // 角色聊天图标
Enable bool // 是否启用被启用
SortNum int //排序数字
ModelId int // 绑定模型ID绑定模型ID的角色只能用指定的模型来问答
Id uint `gorm:"column:id;primaryKey;autoIncrement" json:"id"`
Name string `gorm:"column:name;type:varchar(30);not null;comment:角色名称" json:"name"`
Tid uint `gorm:"column:tid;type:int;not null;comment:分类ID" json:"tid"`
Marker string `gorm:"column:marker;type:varchar(30);uniqueIndex;not null;comment:角色标识" json:"marker"`
Context string `gorm:"column:context_json;type:text;not null;comment:角色语料 json" json:"context_json"`
HelloMsg string `gorm:"column:hello_msg;type:varchar(255);not null;comment:打招呼信息" json:"hello_msg"`
Icon string `gorm:"column:icon;type:varchar(255);not null;comment:角色图标" json:"icon"`
Enable bool `gorm:"column:enable;type:tinyint(1);not null;comment:是否被启用" json:"enable"`
SortNum int `gorm:"column:sort_num;type:smallint;not null;default:0;comment:角色排序" json:"sort_num"`
ModelId uint `gorm:"column:model_id;type:int;not null;default:0;comment:绑定模型ID" json:"model_id"`
CreatedAt time.Time `gorm:"column:created_at;type:datetime;not null" json:"created_at"`
UpdatedAt time.Time `gorm:"column:updated_at;type:datetime;not null" json:"updated_at"`
}
func (m *ChatRole) TableName() string {
return "chatgpt_chat_roles"
}