migrate

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(args []string, fileName string, up, dn string)

Create is the parent func of CreateWithPath Checks migration path in the args if not then set db/migrations/ as default

func CreateSample

func CreateSample(args []string)

CreateSample create blogs migration sample `niom migration -s` invokes this function `niom migration -s seed` may be used generate insert statement

func CreateWithPath

func CreateWithPath(fileName, filePath, up, dn string)

CreateWithPath creates migration file with give fileName and filePath It also accept up and down scripts to add into file while creating it.

func Down

func Down(arg string, args []string)

Down rollback the latest migration `niom migration down` may used to invoke this function

func Status

func Status(args []string)

Status fetch the migration details from the db `niom migration status` invokes this function

func Up

func Up(args []string)

Up migrates the migrations files `niom migration up` may used to invoke this function

Types

type DB

type DB struct{ *sql.DB }

DB holds the database

func GetDB

func GetDB(dbUrl string) *DB

GetDB returns db instance

func (*DB) DeleteRow

func (db *DB) DeleteRow(fileName string) error

Delete row with Given file dedicated to the migration task

func (*DB) Execute

func (db *DB) Execute(sql string) error

Execute sql queries

type MigrationScheme

type MigrationScheme struct {
	ID        int       `db:"id"`
	FileName  string    `db:"file_name"`
	Batch     string    `db:"batch"`
	CreatedAt time.Time `db:"created_at"`
}

MigrationScheme holds migration rows details

Jump to

Keyboard shortcuts

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