backends

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateMigrationTable

func CreateMigrationTable(db *sqlx.DB, query string) (string, error)

func HasMigrationTable

func HasMigrationTable(db *sqlx.DB, query string) (bool, error)

func InsertRecord

func InsertRecord(tx *sqlx.Tx, query string, args ...interface{}) error

func QueryPrevious

func QueryPrevious(db *sqlx.DB, query string) (map[string]string, error)

QueryPrevious runs the query from the Backend.QueryPrevious and returns the results.

func RepairHashes

func RepairHashes(tx *sqlx.Tx, query string, hashes map[string]string) error

Types

type Backend

type Backend interface {
	// Setup does the initial configuration of the backend.
	Setup(db *sqlx.DB, table string, tableSchema string)
	// InsertRecord migration record into the DB.
	InsertRecord(tx *sqlx.Tx, name string, hash string, comment string) error
	// HasMigrationTable returns true if the migration table exists.
	HasMigrationTable() (bool, error)
	// QueryPrevious queries and sets the records of all previous migrations.
	QueryPrevious() (map[string]string, error)
	// CreateMigrationTable makes the migrations table, and return the query used to
	// do it.
	CreateMigrationTable() (string, error)
	RepairHashes(tx *sqlx.Tx, hashes map[string]string) error
}

type MigrationRecord

type MigrationRecord struct {
	ID      int       `db:"id"`
	Name    string    `db:"name"`
	Hash    string    `db:"hash"`
	Date    time.Time `db:"date"`
	Comment string    `db:"comment"`
}

type MySQL

type MySQL struct {
	// contains filtered or unexported fields
}

func (*MySQL) CreateMigrationTable

func (m *MySQL) CreateMigrationTable() (string, error)

CreateMigrationTable makes the migrations table, and return the query used to do it.

func (*MySQL) HasMigrationTable

func (m *MySQL) HasMigrationTable() (bool, error)

HasMigrationTable returns true if the migration table exists.

func (*MySQL) InsertRecord

func (m *MySQL) InsertRecord(tx *sqlx.Tx, name string, hash string, comment string) error

InsertRecord migration record into the DB.

func (*MySQL) QueryPrevious

func (m *MySQL) QueryPrevious() (map[string]string, error)

QueryPrevious queries and sets the records of all previous migrations.

func (*MySQL) RepairHashes

func (m *MySQL) RepairHashes(tx *sqlx.Tx, hashes map[string]string) error

func (*MySQL) Setup

func (m *MySQL) Setup(db *sqlx.DB, table string, tableSchema string)

Setup does the initial configuration of the backend.

type Postgres

type Postgres struct {
	// contains filtered or unexported fields
}

func (*Postgres) CreateMigrationTable

func (p *Postgres) CreateMigrationTable() (string, error)

CreateMigrationTable makes the migrations table, and return the query used to do it.

func (*Postgres) HasMigrationTable

func (p *Postgres) HasMigrationTable() (bool, error)

HasMigrationTable returns true if the migration table exists.

func (*Postgres) InsertRecord

func (p *Postgres) InsertRecord(tx *sqlx.Tx, name string, hash string, comment string) error

InsertRecord migration record into the DB.

func (*Postgres) QueryPrevious

func (p *Postgres) QueryPrevious() (map[string]string, error)

QueryPrevious queries and sets the records of all previous migrations.

func (*Postgres) RepairHashes

func (p *Postgres) RepairHashes(tx *sqlx.Tx, hashes map[string]string) error

func (*Postgres) Setup

func (p *Postgres) Setup(db *sqlx.DB, table string, tableSchema string)

Setup does the initial configuration of the backend.

type SQLite

type SQLite struct {
	// contains filtered or unexported fields
}

func (*SQLite) CreateMigrationTable

func (s *SQLite) CreateMigrationTable() (string, error)

CreateMigrationTable makes the migrations table, and return the query used to do it.

func (*SQLite) HasMigrationTable

func (s *SQLite) HasMigrationTable() (bool, error)

HasMigrationTable returns true if the migration table exists.

func (*SQLite) InsertRecord

func (s *SQLite) InsertRecord(tx *sqlx.Tx, name string, hash string, comment string) error

InsertRecord migration record into the DB.

func (*SQLite) QueryPrevious

func (s *SQLite) QueryPrevious() (map[string]string, error)

QueryPrevious queries and sets the records of all previous migrations.

func (*SQLite) RepairHashes

func (s *SQLite) RepairHashes(tx *sqlx.Tx, hashes map[string]string) error

func (*SQLite) Setup

func (s *SQLite) Setup(db *sqlx.DB, table string, tableSchema string)

Setup does the initial configuration of the backend.

Jump to

Keyboard shortcuts

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