add AppendMigrate
This commit is contained in:
parent
820d7a5c63
commit
f7d8988415
|
@ -15,7 +15,7 @@ import (
|
|||
|
||||
var (
|
||||
// MigrateTables 存储需要在数据库初始化时自动迁移的表
|
||||
MigrateTables []any
|
||||
MigrateTables []any = []any{}
|
||||
)
|
||||
|
||||
// NewDatabase 根据提供的驱动类型创建新的数据库连接
|
||||
|
@ -133,3 +133,10 @@ func NewPostgres(dsn []string, options *types.SqlOptions) (gormDb *gorm.DB, err
|
|||
|
||||
return gormDb, nil
|
||||
}
|
||||
|
||||
// AppendMigrate 调用此函数后,会在数据库初始化时自动迁移表结构
|
||||
//
|
||||
// - table: 需要自动迁移的表
|
||||
func AppendMigrate(table any) {
|
||||
MigrateTables = append(MigrateTables, table)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue