Documentation ¶
Index ¶
- Constants
- func PreInit(pathConfigFile string) error
- type BoltDB
- func (b *BoltDB) CheckMigration(projectName, dbName, version string) (bool, error)
- func (b *BoltDB) Close() error
- func (b *BoltDB) CreateProjectDB(projectName, dbName string) error
- func (b *BoltDB) Delete(post *Migrate) error
- func (b *BoltDB) GetLast(projectName, dbName string, skipNoRollback bool, limit *int) ([]Migrate, error)
- func (b *BoltDB) Init(cfg *Config) error
- func (b *BoltDB) PreInit(cfg *Config) error
- func (b *BoltDB) Up(post *Migrate) error
- type Config
- type Migrate
- type PostgreSQL
- func (p *PostgreSQL) CheckMigration(projectName, dbName, version string) (bool, error)
- func (p *PostgreSQL) Close() error
- func (*PostgreSQL) CreateProjectDB(string, string) error
- func (p *PostgreSQL) Delete(post *Migrate) error
- func (p *PostgreSQL) GetLast(projectName, dbName string, skipNoRollback bool, limit *int) ([]Migrate, error)
- func (p *PostgreSQL) Init(cfg *Config) error
- func (p *PostgreSQL) PreInit(cfg *Config) error
- func (p *PostgreSQL) Up(post *Migrate) error
- type Storage
Constants ¶
const ( TypeBoltDB = "boltdb" TypePostgres = "postgres" )
Allowed database storage types.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoltDB ¶
type BoltDB struct {
// contains filtered or unexported fields
}
BoltDB represents a collection of buckets persisted to a file on disk.
func (*BoltDB) CheckMigration ¶
CheckMigration checks the migration was done successfully.
func (*BoltDB) Close ¶
Close releases all database resources. All transactions must be closed before closing the database.
func (*BoltDB) CreateProjectDB ¶
CreateProjectDB creates a new bucket for project and database if it doesn't already exist.
func (*BoltDB) GetLast ¶
func (b *BoltDB) GetLast(projectName, dbName string, skipNoRollback bool, limit *int) ([]Migrate, error)
GetLast gets a list of recent migrations.
func (*BoltDB) Init ¶
Init creates and opens a database at the given path. If the file does not exist then it will be created automatically.
type Config ¶
type Config struct { StorageType string `yaml:"storage_type"` Path string `yaml:"path"` DSN string `yaml:"dsn"` Schema string `yaml:"schema"` }
Config contains storage credentials information.
type PostgreSQL ¶
type PostgreSQL struct {
// contains filtered or unexported fields
}
PostgreSQL is a database handle representing a pool of zero or more underlying connections.
func (*PostgreSQL) CheckMigration ¶
func (p *PostgreSQL) CheckMigration(projectName, dbName, version string) (bool, error)
CheckMigration checks the migration was done successfully.
func (*PostgreSQL) Close ¶
func (p *PostgreSQL) Close() error
Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.
func (*PostgreSQL) CreateProjectDB ¶
func (*PostgreSQL) CreateProjectDB(string, string) error
CreateProjectDB does nothing. Function is not needed for postgres. Introduced to implement the Storage interface.
func (*PostgreSQL) Delete ¶
func (p *PostgreSQL) Delete(post *Migrate) error
Delete calls migration down.
func (*PostgreSQL) GetLast ¶
func (p *PostgreSQL) GetLast(projectName, dbName string, skipNoRollback bool, limit *int) ([]Migrate, error)
GetLast gets a list of recent migrations.
func (*PostgreSQL) Init ¶
func (p *PostgreSQL) Init(cfg *Config) error
Init opens a database specified by its database driver name and a driver-specific data source name.
func (*PostgreSQL) PreInit ¶
func (p *PostgreSQL) PreInit(cfg *Config) error
PreInit creates migrago table.
type Storage ¶
type Storage interface { PreInit(cfg *Config) error Init(cfg *Config) error Close() error CreateProjectDB(projectName, dbName string) error CheckMigration(projectName, dbName, version string) (bool, error) Up(post *Migrate) error GetLast(projectName, dbName string, skipNoRollback bool, limit *int) ([]Migrate, error) Delete(post *Migrate) error }
Storage describes methods for working with a migration storage.