migrator

package
v1.5.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Migrator

type Migrator struct {
	// MigrationsTable is name of the table that holds current migration version.
	// Each migration set requires a separate MigrationsTable.
	MigrationsTable string

	// Handle is the sql.DB handle used to execute migration statements
	Handle *sql.DB

	// Indicates if migration version should be force reset to latest on file in case of revert to lower version
	// Eg. DB has v3 set in MigrationsTable but latest version in MigrationsDir is v2
	ShouldForceSetLowerVersion bool

	// Indicates if all migrations should be run ignoring the current version in MigrationsTable
	RunAlways bool
}

Migrator is responsible for migrating postgres tables

func (*Migrator) Migrate

func (m *Migrator) Migrate(migrationsDir string) error

Migrate migrates database schema using migration SQL scripts.

func (*Migrator) MigrateFromTemplates

func (m *Migrator) MigrateFromTemplates(templatesDir string, context interface{}) error

MigrateFromTemplates migrates database with migration scripts provided by golang templates. Migration templates are read from all files in templatesDir and converted using provided context as template data. Directories inside templates directory are ignored.

Jump to

Keyboard shortcuts

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