Documentation
¶
Index ¶
- Constants
- func MigrateContext(ctx context.Context, db *gorm.DB) (result error)
- func WithInitializationLock(ctx context.Context, db *gorm.DB, initialize func() error) (result error)
- type PostgresDBConnector
- func (c *PostgresDBConnector) BuildDSNWithTLS() (string, error)
- func (c *PostgresDBConnector) Connect() (*gorm.DB, error)
- func (c *PostgresDBConnector) ConnectContext(ctx context.Context) (*gorm.DB, error)
- func (c *PostgresDBConnector) DB() *gorm.DB
- func (c *PostgresDBConnector) WithMaxRetries(maxRetries int) *PostgresDBConnector
- type PostgresMigrator
Constants ¶
View Source
const (
MigrationDir = "migrations"
)
Variables ¶
This section is empty.
Functions ¶
func MigrateContext ¶ added in v0.3.18
MigrateContext applies migrations on a reserved connection without closing the caller's database pool. golang-migrate uses background contexts for several queries, including advisory-lock acquisition and version-table setup. Closing this connection's transport on cancellation interrupts those queries.
Types ¶
type PostgresDBConnector ¶
type PostgresDBConnector struct {
DSN string
TLSConfig *_tls.TLSConfig
// contains filtered or unexported fields
}
func NewPostgresDBConnector ¶
func NewPostgresDBConnector( dsn string, tlsConfig *_tls.TLSConfig, ) *PostgresDBConnector
func (*PostgresDBConnector) BuildDSNWithTLS ¶
func (c *PostgresDBConnector) BuildDSNWithTLS() (string, error)
BuildDSNWithTLS builds a PostgreSQL DSN with SSL/TLS parameters based on the TLS configuration
func (*PostgresDBConnector) ConnectContext ¶ added in v0.3.18
ConnectContext bounds connection attempts and retry delays by ctx. The returned database handle remains usable after ctx is canceled.
func (*PostgresDBConnector) DB ¶
func (c *PostgresDBConnector) DB() *gorm.DB
func (*PostgresDBConnector) WithMaxRetries ¶
func (c *PostgresDBConnector) WithMaxRetries(maxRetries int) *PostgresDBConnector
type PostgresMigrator ¶
type PostgresMigrator struct {
// contains filtered or unexported fields
}
func NewPostgresMigrator ¶
func NewPostgresMigrator(db *gorm.DB) (*PostgresMigrator, error)
func (*PostgresMigrator) Down ¶
func (m *PostgresMigrator) Down(steps *int) error
func (*PostgresMigrator) Migrate ¶
func (m *PostgresMigrator) Migrate() error
func (*PostgresMigrator) Up ¶
func (m *PostgresMigrator) Up(steps *int) error
Click to show internal directories.
Click to hide internal directories.