base

package
v0.0.13-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColumnType

func ColumnType(ctx *schema.MigratorContext, options schema.ColumnData) func() string

Types

type Schema

type Schema struct {
	// TX is the transaction to execute the queries.
	TX schema.DB

	// DB is a database connection but not in a transaction.
	DB schema.DB

	Context *schema.MigratorContext

	// ReversibleMigrationExecutor is a helper to execute reversible migrations in change method.
	*schema.ReversibleMigrationExecutor
}

Schema is the base schema. It is used to support unknown database types and provide a default implementation.

func NewBase

func NewBase(ctx *schema.MigratorContext, tx schema.DB, db schema.DB) *Schema

NewBase creates a new base schema.

func (*Schema) AddVersion

func (p *Schema) AddVersion(version string)

AddVersion adds a new version to the schema_migrations table. This function is not reversible.

func (Schema) AddVersions

func (p Schema) AddVersions(versions []string)

func (*Schema) BaseDropIndex

func (p *Schema) BaseDropIndex(
	options schema.DropIndexOptions,
	onRollback func(table schema.TableName, columns []string, opts schema.IndexOptions),
)

BaseDropIndex drops an index from the table. Generic method to drop an index across all databases.

func (*Schema) Exec

func (p *Schema) Exec(query string, args ...interface{})

func (*Schema) FindAppliedVersions

func (p *Schema) FindAppliedVersions() []string

FindAppliedVersions returns all the applied versions in the schema_migrations table.

func (*Schema) Query

func (p *Schema) Query(query string, args []interface{}, rowHandler func(row *sql.Rows) error)

func (*Schema) RemoveVersion

func (p *Schema) RemoveVersion(version string)

RemoveVersion removes a version from the schema_migrations table. This function is not reversible.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL