Documentation ¶
Index ¶
- Variables
- func CleanAndMigrateModels(tx *gorm.DB, models ...interface{}) error
- func DropModels(tx *gorm.DB, models ...interface{}) error
- func GetDBFromEnvVars() (*gorm.DB, error)
- func GetTestDBFromEnvVars() (*gorm.DB, error)
- func MigrateModels(tx *gorm.DB, models ...interface{}) error
- type ArrayString
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyDatabaseName is returned when a database configuration contains an empty database name ErrEmptyDatabaseName = errors.New("db config contains empty database name") )
Functions ¶
func CleanAndMigrateModels ¶
CleanAndMigrateModels drops existing target model tables and recreates them.
func DropModels ¶
DropModels drops database models.
func GetDBFromEnvVars ¶
GetDBFromEnvVars reads environment variables to return a Gorm database connection.
func GetTestDBFromEnvVars ¶
GetTestDBFromEnvVars reads environment variables to return a Gorm database connection to a test database. The test database will have "_test" automatically appended to the target database name.
func MigrateModels ¶
MigrateModels migrates database models. If the model table already exists, it will be updated to reflect the model structure. The table will only have columns added or updated but not dropped.
Types ¶
type ArrayString ¶ added in v8.10.0
type ArrayString []string
ArrayString is a custom data type for SQL databases. It adds support for an array of strings to MySQL.
func (*ArrayString) Scan ¶ added in v8.10.0
func (arr *ArrayString) Scan(src any) error
Scan fills out the current ArrayString with the string provided as source. It returns an error if source if not a string.
See sql.Scanner for more details.