Documentation
¶
Overview ¶
Package base provides common functionality for Queen database drivers.
Package base provides common functionality for database drivers.
Package base provides common functionality for database drivers.
Package base provides common functionality for database drivers.
Index ¶
- func AcquireTableLock(ctx context.Context, db *sql.DB, config TableLockConfig, ...) error
- func GenerateOwnerID() (string, error)
- func ParseTimeISO8601(src any) (time.Time, error)
- func PlaceholderAtSign(n int) string
- func PlaceholderDollar(n int) string
- func PlaceholderQuestion(n int) string
- func QuoteBackticks(name string) string
- func QuoteBrackets(name string) string
- func QuoteDoubleQuotes(name string) string
- func QuoteIdentifier(name string, quoteChar QuoteChar) string
- type Config
- type Driver
- func (d *Driver) Close() error
- func (d *Driver) Exec(ctx context.Context, isolationLevel sql.IsolationLevel, fn func(*sql.Tx) error) error
- func (d *Driver) GetApplied(ctx context.Context) ([]queen.Applied, error)
- func (d *Driver) Record(ctx context.Context, m *queen.Migration, meta *queen.MigrationMetadata) error
- func (d *Driver) Remove(ctx context.Context, version string) error
- type QuoteChar
- type TableLockConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireTableLock ¶ added in v0.2.0
func AcquireTableLock(ctx context.Context, db *sql.DB, config TableLockConfig, lockKey, ownerID string, timeout time.Duration) error
AcquireTableLock implements distributed locking using a lock table. Retries with exponential backoff until lock is acquired or timeout is reached.
func GenerateOwnerID ¶ added in v0.2.0
GenerateOwnerID generates a unique owner identifier for lock ownership tracking.
func ParseTimeISO8601 ¶
ParseTimeISO8601 parses time from ISO8601 string format.
func PlaceholderAtSign ¶ added in v0.3.0
PlaceholderAtSign creates placeholders in the format @p1, @p2, @p3... Used for MS SQL Server which requires named parameters.
func PlaceholderDollar ¶
PlaceholderDollar creates placeholders in the format $1, $2, $3...
func PlaceholderQuestion ¶
PlaceholderQuestion creates placeholders in the format ?, ?, ?...
func QuoteBackticks ¶
QuoteBackticks is a convenience wrapper for QuoteIdentifier with Backtick.
func QuoteBrackets ¶ added in v0.2.0
QuoteBrackets is a convenience wrapper for QuoteIdentifier with Bracket.
func QuoteDoubleQuotes ¶
QuoteDoubleQuotes is a convenience wrapper for QuoteIdentifier with DoubleQuote.
func QuoteIdentifier ¶
QuoteIdentifier escapes and wraps a SQL identifier using the provided quote character.
Types ¶
type Config ¶
type Config struct {
Placeholder func(n int) string
QuoteIdentifier func(name string) string
ParseTime func(src interface{}) (time.Time, error)
}
Config contains configuration for the base driver.
type Driver ¶
Driver provides a base implementation of common queen.Driver methods. Concrete drivers should embed this type and implement Init() and Lock()/Unlock().
func (*Driver) Exec ¶
func (d *Driver) Exec(ctx context.Context, isolationLevel sql.IsolationLevel, fn func(*sql.Tx) error) error
Exec executes a function within a transaction with the specified isolation level.
func (*Driver) GetApplied ¶
GetApplied returns all applied migrations sorted by applied_at.