migrate

package
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2014 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Driver func(tx *sql.Tx) Operation
View Source
var GitHubEnterpriseSupport = &Rev3{}
View Source
var RenamePrivelegedToPrivileged = &Rev1{}

Functions

This section is empty.

Types

type Migration

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

func New

func New(db *sql.DB) *Migration

func (*Migration) Add

func (m *Migration) Add(rev ...Revision) *Migration

Add the Revision to the list of migrations.

func (*Migration) All

func (m *Migration) All() *Migration

func (*Migration) Migrate

func (m *Migration) Migrate() error

Execute the full list of migrations.

func (*Migration) MigrateTo

func (m *Migration) MigrateTo(target int64) error

Execute all database migration until you are at the specified revision number. If the revision number is less than the current revision, then we will downgrade.

type MigrationDriver

type MigrationDriver struct {
	Tx *sql.Tx
}

type Operation

type Operation interface {
	CreateTable(tableName string, args []string) (sql.Result, error)

	RenameTable(tableName, newName string) (sql.Result, error)

	DropTable(tableName string) (sql.Result, error)

	AddColumn(tableName, columnSpec string) (sql.Result, error)

	DropColumns(tableName string, columnsToDrop []string) (sql.Result, error)

	RenameColumns(tableName string, columnChanges map[string]string) (sql.Result, error)

	Exec(query string, args ...interface{}) (sql.Result, error)

	Query(query string, args ...interface{}) (*sql.Rows, error)

	QueryRow(query string, args ...interface{}) *sql.Row
}

Operation interface covers basic migration operations. Implementation details is specific for each database, see migrate/sqlite.go for implementation reference.

func SQLite

func SQLite(tx *sql.Tx) Operation

type Rev1

type Rev1 struct{}

func (*Rev1) Down

func (r *Rev1) Down(op Operation) error

func (*Rev1) Revision

func (r *Rev1) Revision() int64

func (*Rev1) Up

func (r *Rev1) Up(op Operation) error

type Rev3

type Rev3 struct{}

func (*Rev3) Down

func (r *Rev3) Down(op Operation) error

func (*Rev3) Revision

func (r *Rev3) Revision() int64

func (*Rev3) Up

func (r *Rev3) Up(op Operation) error

type Revision

type Revision interface {
	Up(op Operation) error
	Down(op Operation) error
	Revision() int64
}

type SQLiteDriver

type SQLiteDriver MigrationDriver

func (*SQLiteDriver) AddColumn

func (s *SQLiteDriver) AddColumn(tableName, columnSpec string) (sql.Result, error)

func (*SQLiteDriver) CreateTable

func (s *SQLiteDriver) CreateTable(tableName string, args []string) (sql.Result, error)

func (*SQLiteDriver) DropColumns

func (s *SQLiteDriver) DropColumns(tableName string, columnsToDrop []string) (sql.Result, error)

func (*SQLiteDriver) DropTable

func (s *SQLiteDriver) DropTable(tableName string) (sql.Result, error)

func (*SQLiteDriver) Exec

func (s *SQLiteDriver) Exec(query string, args ...interface{}) (sql.Result, error)

func (*SQLiteDriver) Query

func (s *SQLiteDriver) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*SQLiteDriver) QueryRow

func (s *SQLiteDriver) QueryRow(query string, args ...interface{}) *sql.Row

func (*SQLiteDriver) RenameColumns

func (s *SQLiteDriver) RenameColumns(tableName string, columnChanges map[string]string) (sql.Result, error)

func (*SQLiteDriver) RenameTable

func (s *SQLiteDriver) RenameTable(tableName, newName string) (sql.Result, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL