package migrations
Import Path
github.com/go-pg/migrations/v8 (on go.dev )
Dependency Relation
imports 20 packages , and imported by one package
Package-Level Type Names (total 4, in which 3 are exported)
/* sort exporteds by: alphabet | popularity */
type Collection (struct)
Fields (total 5, none are exported )
/* 5 unexporteds ... */ /* 5 unexporteds: */
migrations []*Migration
// sorted
mu sync .Mutex
sqlAutodiscoverDisabled bool
tableName string
visitedDirs map[string ]struct{}
Methods (total 24, in which 12 are exported )
(*Collection) DisableSQLAutodiscover (flag bool ) *Collection
(*Collection) DiscoverSQLMigrations (dir string ) error
DiscoverSQLMigrations scan the dir for files with .sql extension
and adds discovered SQL migrations to the collection.
(*Collection) DiscoverSQLMigrationsFromFilesystem (fs http .FileSystem , dir string ) error
DiscoverSQLMigrations scan the dir from the given filesystem for files with .sql extension
and adds discovered SQL migrations to the collection.
(*Collection) Migrations () []*Migration
(*Collection) MustRegister (fns ...func(DB ) error )
(*Collection) MustRegisterTx (fns ...func(DB ) error )
(*Collection) Register (fns ...func(DB ) error ) error
Register registers new database migration. Must be called
from a file with name like "1_initialize_db.go".
(*Collection) RegisterTx (fns ...func(DB ) error ) error
RegisterTx is like Register, but migration will be run in a transaction.
(*Collection) Run (db DB , a ...string ) (oldVersion, newVersion int64 , err error )
(*Collection) SetTableName (tableName string ) *Collection
(*Collection) SetVersion (db DB , version int64 ) error
(*Collection) Version (db DB ) (int64 , error )
/* 12 unexporteds ... */ /* 12 unexporteds: */
(*Collection) addMigration (migration *Migration )
(*Collection) begin (db DB ) (*pg .Tx , int64 , error )
(*Collection) createTable (db DB ) error
(*Collection) down (db DB , tx *pg .Tx , migrations []*Migration , oldVersion int64 ) (int64 , error )
(*Collection) isVisitedDir (dir string ) bool
(*Collection) register (tx bool , fns ...func(DB ) error ) error
(*Collection) run (tx *pg .Tx , fn func() (int64 , error )) (newVersion int64 , err error )
(*Collection) runDown (db DB , tx *pg .Tx , m *Migration ) (int64 , error )
(*Collection) runUp (db DB , tx *pg .Tx , m *Migration ) (int64 , error )
(*Collection) schemaExists (db DB ) (bool , error )
(*Collection) schemaTableName () (string , string )
(*Collection) tableExists (db DB ) (bool , error )
As Outputs Of (at least 3, all are exported )
func NewCollection (migrations ...*Migration ) *Collection
func (*Collection).DisableSQLAutodiscover (flag bool ) *Collection
func (*Collection).SetTableName (tableName string ) *Collection
As Types Of (only one, which is exported )
var DefaultCollection *Collection
type DB (interface)
DB is a common interface for pg.DB and pg.Tx types.
Methods (total 9, all are exported )
( DB) Begin () (*pg .Tx , error )
( DB) Context () context .Context
( DB) CopyFrom (r io .Reader , query interface{}, params ...interface{}) (orm .Result , error )
( DB) CopyTo (w io .Writer , query interface{}, params ...interface{}) (orm .Result , error )
( DB) Exec (query interface{}, params ...interface{}) (orm .Result , error )
( DB) ExecOne (query interface{}, params ...interface{}) (orm .Result , error )
( DB) Model (model ...interface{}) *orm .Query
( DB) Query (coll, query interface{}, params ...interface{}) (orm .Result , error )
( DB) QueryOne (model, query interface{}, params ...interface{}) (orm .Result , error )
Implemented By (at least 3, all are exported )
*github.com/go-pg/pg/v10.Conn
*github.com/go-pg/pg/v10.DB
*github.com/go-pg/pg/v10.Tx
As Inputs Of (at least 13, in which 6 are exported )
func Run (db DB , a ...string ) (oldVersion, newVersion int64 , err error )
func SetVersion (db DB , version int64 ) error
func Version (db DB ) (int64 , error )
func (*Collection ).Run (db DB , a ...string ) (oldVersion, newVersion int64 , err error )
func (*Collection ).SetVersion (db DB , version int64 ) error
func (*Collection ).Version (db DB ) (int64 , error )
/* 7+ unexporteds ... */ /* 7+ unexporteds: */
func (*Collection ).begin (db DB ) (*pg .Tx , int64 , error )
func (*Collection ).createTable (db DB ) error
func (*Collection ).down (db DB , tx *pg .Tx , migrations []*Migration , oldVersion int64 ) (int64 , error )
func (*Collection ).runDown (db DB , tx *pg .Tx , m *Migration ) (int64 , error )
func (*Collection ).runUp (db DB , tx *pg .Tx , m *Migration ) (int64 , error )
func (*Collection ).schemaExists (db DB ) (bool , error )
func (*Collection ).tableExists (db DB ) (bool , error )
type Migration (struct)
Fields (total 5, all are exported )
Down func(DB ) error
DownTx bool
Up func(DB ) error
UpTx bool
Version int64
Methods (only one, which is exported )
(*Migration) String () string
Implements (at least 5, in which 2 are exported )
*Migration : expvar.Var
*Migration : fmt.Stringer
/* 3+ unexporteds ... */ /* 3+ unexporteds: */
*Migration : github.com/aws/smithy-go/middleware.stringer
*Migration : context.stringer
*Migration : runtime.stringer
As Outputs Of (at least 4, in which 3 are exported )
func RegisteredMigrations () []*Migration
func (*Collection ).Migrations () []*Migration
func go.pact.im/x/old/pgtxtar.LoadFS (fsys fs .FS ) ([]*Migration , error )
/* at least one unexported ... */ /* at least one unexported: */
func insert (s []*Migration , i int , x *Migration ) []*Migration
As Inputs Of (at least 8, in which 1 are exported )
func NewCollection (migrations ...*Migration ) *Collection
/* 7+ unexporteds ... */ /* 7+ unexporteds: */
func insert (s []*Migration , i int , x *Migration ) []*Migration
func insert (s []*Migration , i int , x *Migration ) []*Migration
func validateMigrations (migrations []*Migration ) error
func (*Collection ).addMigration (migration *Migration )
func (*Collection ).down (db DB , tx *pg .Tx , migrations []*Migration , oldVersion int64 ) (int64 , error )
func (*Collection ).runDown (db DB , tx *pg .Tx , m *Migration ) (int64 , error )
func (*Collection ).runUp (db DB , tx *pg .Tx , m *Migration ) (int64 , error )