generic

package
v3.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 6 Imported by: 18

Documentation

Overview

Package generic implements a generic driver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dialect

type Dialect interface {
	CreateTableSQL() string
	InsertSQL() string
	UpdateChecksumSQL() string
	AllSQL() string
}

Dialect is used to support multiple databases by returning proper SQL.

type Driver

type Driver struct {
	DB      *sql.DB
	Dialect Dialect
}

Driver is the default Driver, it can be configured to any database.

func New

func New(db *sql.DB, dialect Dialect) (*Driver, error)

New creates a new GenericDriver configured with db and dialect.

func (*Driver) All

func (d *Driver) All() ([]darwin.MigrationRecord, error)

All returns all migrations applied.

func (*Driver) Create

func (d *Driver) Create() error

Create create the table darwin_migrations if necessary.

func (*Driver) Exec

func (d *Driver) Exec(script string) (time.Duration, error)

Exec execute sql scripts into database.

func (*Driver) Insert

func (d *Driver) Insert(e darwin.MigrationRecord) error

Insert insert a migration entry into database.

func (*Driver) UpdateChecksum

func (d *Driver) UpdateChecksum(checksum string, version float64) error

UpdateChecksum updates all the checksums for the migration into the database.

Jump to

Keyboard shortcuts

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