Documentation ¶
Overview ¶
Copyright 2020 The Moov Authors Use of this source code is governed by an Apache License license that can be found in the LICENSE file.
Copyright 2020 The Moov Authors Use of this source code is governed by an Apache License license that can be found in the LICENSE file.
Copyright 2020 The Moov Authors Use of this source code is governed by an Apache License license that can be found in the LICENSE file.
Copyright 2020 The Moov Authors Use of this source code is governed by an Apache License license that can be found in the LICENSE file.
Copyright 2020 The Moov Authors Use of this source code is governed by an Apache License license that can be found in the LICENSE file.
Index ¶
- Constants
- func ApplyConnectionsConfig(db *sql.DB, connections *ConnectionsConfig, logger log.Logger) *sql.DB
- func DataTooLong(err error) bool
- func GetDriver(logger log.Logger, config DatabaseConfig) (source.Driver, database.Driver, error)deprecated
- func LoadTLSClientCertFromFile(logger log.Logger, certFile, keyFile string) (tls.Certificate, error)
- func LoadTLSClientCertsFromConfig(logger log.Logger, config *MySQLConfig) ([]tls.Certificate, error)
- func MySQLDataTooLong(err error) bool
- func MySQLDeadlockFound(err error) bool
- func MySQLDriver(db *sql.DB) (database.Driver, error)
- func MySQLUniqueViolation(err error) bool
- func New(ctx context.Context, logger log.Logger, config DatabaseConfig) (*sql.DB, error)
- func NewAndMigrate(ctx context.Context, logger log.Logger, config DatabaseConfig, ...) (*sql.DB, error)
- func NewPkgerSource(database string, allowGeneric bool) (source.Driver, error)
- func NopInTx() error
- func PostgresDriver(db *sql.DB) (database.Driver, error)
- func PostgresUniqueViolation(err error) bool
- func RecordMySQLStats(db *sql.DB) error
- func RunMigrations(logger log.Logger, config DatabaseConfig, opts ...MigrateOption) error
- func RunMigrationsContext(ctx context.Context, logger log.Logger, config DatabaseConfig, ...) error
- func SpannerDriver(config DatabaseConfig) (database.Driver, error)
- func SpannerMigrationDriver(cfg SpannerConfig, databaseName string) (database.Driver, error)
- func SpannerUniqueViolation(err error) bool
- func UniqueViolation(err error) bool
- type ConnectionsConfig
- type DatabaseConfig
- type ErrOpenConnections
- type MigrateOption
- type MySQLConfig
- type PostgresAlloyConfig
- type PostgresConfig
- type PostgresTLSConfig
- type RunInTx
- type SourceDriver
- type SpannerConfig
- type TLSClientCertConfig
Constants ¶
const MIGRATIONS_DIR = "/migrations/"
Variables ¶
This section is empty.
Functions ¶
func ApplyConnectionsConfig ¶ added in v0.17.0
func DataTooLong ¶ added in v0.32.0
func LoadTLSClientCertFromFile ¶ added in v0.35.0
func LoadTLSClientCertsFromConfig ¶ added in v0.35.0
func LoadTLSClientCertsFromConfig(logger log.Logger, config *MySQLConfig) ([]tls.Certificate, error)
func MySQLDataTooLong ¶ added in v0.32.0
MySQLDataTooLong returns true when the provided error matches the MySQL code for data too long for column (when trying to insert a value that is greater than the defined max size of the column).
func MySQLDeadlockFound ¶ added in v0.43.0
MySQLDeadlockFound returns true when the provided error matches the MySQL code for deadlock found.
func MySQLUniqueViolation ¶
MySQLUniqueViolation returns true when the provided error matches the MySQL code for duplicate entries (violating a unique table constraint).
func New ¶
New establishes a database connection according to the type and environmental variables for that specific database.
func NewAndMigrate ¶
func NewAndMigrate(ctx context.Context, logger log.Logger, config DatabaseConfig, opts ...MigrateOption) (*sql.DB, error)
func NewPkgerSource ¶ added in v0.15.2
func PostgresUniqueViolation ¶ added in v0.53.0
func RecordMySQLStats ¶ added in v0.27.4
func RunMigrations ¶
func RunMigrations(logger log.Logger, config DatabaseConfig, opts ...MigrateOption) error
func RunMigrationsContext ¶ added in v0.52.0
func RunMigrationsContext(ctx context.Context, logger log.Logger, config DatabaseConfig, opts ...MigrateOption) error
func SpannerDriver ¶ added in v0.40.0
func SpannerDriver(config DatabaseConfig) (database.Driver, error)
func SpannerMigrationDriver ¶ added in v0.40.0
func SpannerMigrationDriver(cfg SpannerConfig, databaseName string) (database.Driver, error)
func SpannerUniqueViolation ¶ added in v0.41.0
SpannerUniqueViolation returns true when the provided error matches the Spanner code for duplicate entries (violating a unique table constraint). Refer to https://cloud.google.com/spanner/docs/error-codes for Spanner error definitions, and https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto for error codes
func UniqueViolation ¶
UniqueViolation returns true when the provided error matches a database error for duplicate entries (violating a unique table constraint).
Types ¶
type ConnectionsConfig ¶ added in v0.17.0
type DatabaseConfig ¶
type DatabaseConfig struct { MySQL *MySQLConfig Spanner *SpannerConfig Postgres *PostgresConfig DatabaseName string }
type ErrOpenConnections ¶ added in v0.14.0
ErrOpenConnections describes the number of open connections that should have been closed by a call to Close(). All queries/transactions should call Close() to prevent unused, open connections.
func (ErrOpenConnections) Error ¶ added in v0.14.0
func (e ErrOpenConnections) Error() string
type MigrateOption ¶ added in v0.44.0
type MigrateOption func(o *migrateOptions) error
func WithEmbeddedMigrations ¶ added in v0.44.0
func WithEmbeddedMigrations(f fs.FS) MigrateOption
func WithTimeout ¶ added in v0.44.0
func WithTimeout(dur time.Duration) MigrateOption
type MySQLConfig ¶
type MySQLConfig struct { Address string User string Password string Connections ConnectionsConfig UseTLS bool TLSCAFile string VerifyCAFile bool TLSClientCerts []TLSClientCertConfig // InsecureSkipVerify is a dangerous option which should be used with extreme caution. // This setting disables multiple security checks performed with TLS connections. InsecureSkipVerify bool }
func (*MySQLConfig) MarshalJSON ¶ added in v0.20.0
func (m *MySQLConfig) MarshalJSON() ([]byte, error)
type PostgresAlloyConfig ¶ added in v0.53.0
type PostgresConfig ¶ added in v0.53.0
type PostgresConfig struct { Address string User string Password string Connections ConnectionsConfig TLS *PostgresTLSConfig Alloy *PostgresAlloyConfig }