mysql

package
v0.0.0-...-8c930d8 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DryRun

func DryRun() (*gorm.DB, error)

DryRun returns a handle on the MySQL dialect that never connects: gorm's dry-run mode builds statements without running them, the version query of the dialect's initialization is skipped and no ping is made. It answers schema questions where no server is at hand, above all the column type a field gets on MySQL: the column inspection gg builds into a project validates the models' index declarations against it (see model.ValidateIndexes), which is how gg check refuses a declaration MySQL cannot honor without a database. The handle logs nothing, since it runs nothing.

func Init

func Init() error

Init opens the default MySQL connection when MySQL is enabled and selected as the default database, and makes it the default database that database.Database and database.DB use; otherwise it does nothing.

func New

func New(cfg config.MySQL) (*gorm.DB, error)

New creates and returns a new MySQL database connection with the given configuration. With tracing configured on, the returned handle carries the GORM OpenTelemetry tracing plugin, so application-held instances passed to DatabaseOn, SelectOn, UnionAllOn, TransactionOn, and CleanupOn are traced like the default database. The pool runs under the connection limits of the [database] configuration, the same ones the default handle runs under.

Types

This section is empty.

Jump to

Keyboard shortcuts

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