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
- func RecordTx(ctx context.Context, d *Driver, tx *sql.Tx, m *queen.Migration, ...) error
- func RemoveTx(ctx context.Context, d *Driver, tx *sql.Tx, version string) error
- 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
- func (d *Driver) SQLDB() *sql.DB
- type QuoteChar
- type TableLockConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AcquireTableLock ¶
func AcquireTableLock(ctx context.Context, db *sql.DB, config TableLockConfig, lockKey, ownerID string, timeout time.Duration) error
AcquireTableLock retries a table-backed lock until it is acquired or times out.
func GenerateOwnerID ¶
GenerateOwnerID generates a unique owner identifier for lock ownership tracking.
func ParseTimeISO8601 ¶
ParseTimeISO8601 parses common SQLite timestamp and ISO-8601 string formats.
func PlaceholderAtSign ¶
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 ¶
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 any) (time.Time, error)
}
Config contains configuration for the base driver.
type Driver ¶
Driver holds the shared database handle and migration-table helpers.
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.
func (*Driver) Record ¶
func (d *Driver) Record(ctx context.Context, m *queen.Migration, meta *queen.MigrationMetadata) error
Record marks a migration as applied in the database.