Documentation
¶
Index ¶
- func AutoMigrate(index string, dst ...interface{}) error
- func ClearIndexCache()
- func Connect() (*gorm.DB, error)
- func DB() *gorm.DB
- func EnsureTables(dst ...interface{}) error
- func GetIndexHeight(name string) (uint64, error)
- func LoadDBFromEnv() (*gorm.DB, error)
- func SetDB(gormDB *gorm.DB)
- func UpdateIndexHeight(name string, height uint64) error
- func UpdateIndexHeightByTx(tx *gorm.DB, name string, height uint64) error
- type BaseModel
- type IndexHeight
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoMigrate ¶ added in v1.4.0
AutoMigrate run auto migration for given models
func ClearIndexCache ¶ added in v1.18.0
func ClearIndexCache()
ClearIndexCache clears the in-memory index height cache, intended for testing only.
func EnsureTables ¶ added in v1.18.2
func EnsureTables(dst ...interface{}) error
EnsureTables creates any of the given tables that don't already exist, without dropping any data. Intended for tables introduced after a plugin was first deployed: AutoMigrate's drop-then-recreate only runs at index height 0, so on upgrade new tables would otherwise never be created.
Safe to call alongside AutoMigrate: at height 0 the tables AutoMigrate just created exist already, so EnsureTables is a no-op; at height > 0 AutoMigrate is a no-op and EnsureTables creates only what's missing.
func GetIndexHeight ¶
func LoadDBFromEnv ¶ added in v1.4.0
func UpdateIndexHeight ¶
Types ¶
type IndexHeight ¶
type IndexHeight struct {
ID uint32 `gorm:"primary_key;auto_increment"`
Name string `gorm:"size:128;not null;unique"`
Height uint64 `sql:"type:bigint"`
}
func (*IndexHeight) ByName ¶
func (m *IndexHeight) ByName(name string) (*IndexHeight, error)
Click to show internal directories.
Click to hide internal directories.