amigo

package
v0.0.7-alpha Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectionNil   = errors.New("connection is nil")
	ErrMigrationFailed = errors.New("migration failed")
)

Functions

This section is empty.

Types

type Amigo

type Amigo struct {
	Driver types.Driver
	// contains filtered or unexported fields
}

func NewAmigo

func NewAmigo(ctx *amigoctx.Context) Amigo

NewAmigo create a new amigo instance

func (Amigo) DumpSchema

func (a Amigo) DumpSchema() (string, error)

DumpSchema of the database and write it to the writer

func (Amigo) ExecuteMain

func (a Amigo) ExecuteMain(arg MainArg) error

func (Amigo) GenerateMainFile

func (a Amigo) GenerateMainFile(writer io.Writer) error

GenerateMainFile generate the main.go file in the amigo folder

func (Amigo) GenerateMigrationFile

func (a Amigo) GenerateMigrationFile(params *GenerateMigrationFileParams) error

GenerateMigrationFile generate a migration file in the migrations folder

func (Amigo) GenerateMigrationsFiles

func (a Amigo) GenerateMigrationsFiles(writer io.Writer) error

GenerateMigrationsFiles generate the migrations file in the migrations folder It's used to keep track of all migrations

func (Amigo) GetMigrationFiles

func (a Amigo) GetMigrationFiles(ascending bool) (map[time.Time]string, []time.Time, error)

func (Amigo) RunMigrations

func (a Amigo) RunMigrations(params RunMigrationParams) error

RunMigrations migrates the database, it is launched via the generated main file or manually in a codebase.

func (Amigo) SetupSlog

func (a Amigo) SetupSlog(writer io.Writer)

func (Amigo) SkipMigrationFile

func (a Amigo) SkipMigrationFile(db *sql.DB) error

type GenerateMigrationFileParams

type GenerateMigrationFileParams struct {
	Name            string
	Up              string
	Down            string
	Change          string
	Type            types.MigrationFileType
	Now             time.Time
	UseSchemaImport bool
	UseFmtImport    bool
	Writer          io.Writer
}

type MainArg

type MainArg string
const (
	MainArgMigrate       MainArg = "migrate"
	MainArgRollback      MainArg = "rollback"
	MainArgSkipMigration MainArg = "skip-migration"
)

func (MainArg) Validate

func (m MainArg) Validate() error

type RunMigrationParams

type RunMigrationParams struct {
	DB         *sql.DB
	Direction  types.MigrationDirection
	Migrations []schema.Migration
	LogOutput  io.Writer
}

Jump to

Keyboard shortcuts

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