package sqladapter
import "github.com/pressly/goose/v3/internal/sqladapter"
Package sqladapter provides an interface for interacting with a SQL database.
All supported database dialects must implement the Store interface.
Index ¶
Types ¶
type GetMigrationResult ¶
type ListMigrationsResult ¶
type Store ¶
type Store interface { // CreateVersionTable creates the version table within a transaction. This table is used to // record applied migrations. CreateVersionTable(ctx context.Context, db sqlextended.DBTxConn) error // InsertOrDelete inserts or deletes a version id from the version table. InsertOrDelete(ctx context.Context, db sqlextended.DBTxConn, direction bool, version int64) error // GetMigration retrieves a single migration by version id. // // Returns the raw sql error if the query fails. It is the callers responsibility to assert for // the correct error, such as [sql.ErrNoRows]. GetMigration(ctx context.Context, db sqlextended.DBTxConn, version int64) (*GetMigrationResult, error) // ListMigrations retrieves all migrations sorted in descending order by id. // // If there are no migrations, an empty slice is returned with no error. ListMigrations(ctx context.Context, db sqlextended.DBTxConn) ([]*ListMigrationsResult, error) }
Store is the interface that wraps the basic methods for a database dialect.
A dialect is a set of SQL statements that are specific to a database.
By defining a store interface, we can support multiple databases with a single codebase.
The underlying implementation does not modify the error. It is the callers responsibility to assert for the correct error, such as [sql.ErrNoRows].
func NewStore ¶
NewStore returns a new Store backed by the given dialect.
The dialect must match one of the supported dialects defined in dialect.go.
Source Files ¶
- Version
- v3.15.1
- Published
- Oct 10, 2023
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 2 hours ago –
Tools for package owners.