Documentation ¶
Overview ¶
Package sql implements a generic adapter for SQL databases. It uses only the database/sql standard package.
Index ¶
- Constants
- type Adapter
- func (a *Adapter) Exec(command string) error
- func (a *Adapter) GetAll() ([]*migrataur.Migration, error)
- func (a *Adapter) GetInitialMigration() (up, down string)
- func (a *Adapter) MigrationApplied(migration *migrataur.Migration) error
- func (a *Adapter) MigrationRollbacked(migration *migrataur.Migration) error
Constants ¶
const DefaultPlaceholder = "?"
DefaultPlaceholder holds the default value for the sql placeholder If you're on postgres, you should use ${i} where {i} will be replaced by the arg position. See PostgrePlaceholder.
const DefaultTableName = "__migrations"
DefaultTableName represents the default name of the migrations table
const PostgrePlaceholder = "${i}"
PostgrePlaceholder holds the default placeholder for pg databases.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements the interface defined by migrataur for common SQL databases
func WithDB ¶
WithDB constructs a sql adapter with the given DB handle. It will use the default tableName "__migrations" and "?" placeholder.
func WithDBAndOptions ¶
WithDBAndOptions constructs a sql adapter with the given DB handle and options. table is the the name of the migrations table and placeholder is DB dependent. If you're on postgres, you should use ${i} where {i} will be replaced by the arg position.
func (*Adapter) Exec ¶
Exec the given commands. This is call by Migrataur to apply or rollback a migration with the corresponding code.
func (*Adapter) GetInitialMigration ¶
GetInitialMigration retrieves the migration up and down code and is used to populate the migrations history table.
func (*Adapter) MigrationApplied ¶
MigrationApplied is called when the migration has been successfully applied by the adapter. This is where you should insert the migration in the history.