migrate

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2023 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ORDER_ASC  = "ASC"
	ORDER_DESC = "DESC"

	MIGS_QUERY = `
	SELECT migration_id, name 
	FROM migrations 
	WHERE migrations.migrated = ? [batch] 
	ORDER BY migration_id [order];
`

	MIGS_TABLE = `` /* 307-byte string literal not displayed */

	MIGRATE_DEFAULT = `-- add your UP SQL here

-- [DIRECTION] -- do not alter this line!
-- add your DOWN SQL here

`
	LAST_BATCH_QUERY = "SELECT batch_id FROM migrations where migrated = 1 ORDER BY migration_id DESC LIMIT 1"
	EXISTS_QUERY     = "SELECT count(*) as taken FROM migrations WHERE name = ?;"
	PERM             = 0700 // this is to give the caller full rights, but no other user or group.
	REMOVE_FILE      = `DELETE FROM migrations WHERE migrations.name = ?`
)
View Source
const (
	TEST_USERS_TABLE_MIG = `` /* 484-byte string literal not displayed */

	TEST_ALTER_USERS_MIG = `` /* 211-byte string literal not displayed */

	TEST_TABLE_ONE = `` /* 401-byte string literal not displayed */

	TEST_ALTER_TABLE_ONE = `` /* 210-byte string literal not displayed */

	TEST_MIG_TO_BE_REMOVED = `` /* 225-byte string literal not displayed */

)

Variables

View Source
var (
	Permission os.FileMode = PERM
)

Functions

func DirExists

func DirExists(path string) (bool, error)

func GetErrors

func GetErrors(errs []error) error

func GetFileContents

func GetFileContents(fileName string) (string, error)

GetFileContents gets file contents from the file at the path

Types

type Migration

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

Migration is a migration

func Make

func Make(database *database.Database, path string) *Migration

Make creates a new migration

func (*Migration) Create

func (m *Migration) Create(migrationName string) (fullPath, fullname, message string, err error)

Create makes a new migration file

func (*Migration) MigrateDown

func (m *Migration) MigrateDown() (string, error)

func (*Migration) MigrateUp

func (m *Migration) MigrateUp() (string, error)

Jump to

Keyboard shortcuts

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