source

package
v0.0.0-...-10cedd8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInitDBService

func NewInitDBService(db *gorm.DB) *initDBService

func RegisterInit

func RegisterInit(i SubInitializer)

RegisterInit 注册要执行的初始化过程,会在 InitDB() 时调用

Types

type InitHandler

type InitHandler interface {
	InitTables(ctx context.Context, inits initSlice) error // 建表 handler
}

type SubInitializer

type SubInitializer interface {
	InitializerName() string // 不一定代表单独一个表,所以改成了更宽泛的语义
	MigrateTable(ctx context.Context, db *gorm.DB) error
	InitializeData(ctx context.Context, db *gorm.DB) error
	TableCreated(ctx context.Context, db *gorm.DB) bool
}

type SystemInitTable

type SystemInitTable struct {
}

func (*SystemInitTable) InitializeData

func (s *SystemInitTable) InitializeData(ctx context.Context, db *gorm.DB) error

func (*SystemInitTable) InitializerName

func (s *SystemInitTable) InitializerName() string

func (*SystemInitTable) MigrateTable

func (s *SystemInitTable) MigrateTable(ctx context.Context, db *gorm.DB) error

func (*SystemInitTable) TableCreated

func (s *SystemInitTable) TableCreated(ctx context.Context, db *gorm.DB) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL