Documentation ¶
Index ¶
- func BuildMigrationMap(db *sqlx.DB) (migrationsMap map[string]struct{}, err error)
- func InitializeDB(ea EngineAdapter, c Connection) error
- func InitializeMigrationTable(ea EngineAdapter, c Connection) (*sqlx.DB, error)
- func ProcessFiles(db *sqlx.DB, migrationsMap map[string]struct{}, migrationPath string) error
- func ProcessMigration(db *sqlx.DB, migrationPath, fileName string) error
- func StartMigration(c Connection) error
- func ValidFile(file fs.DirEntry) bool
- type Connection
- type EngineAdapter
- type EngineType
- type Migration
- type Mock
- func (m *Mock) CheckDB(db *sqlx.DB, c Connection) error
- func (m *Mock) CheckTable(db *sqlx.DB, c Connection) error
- func (m *Mock) CheckUser(db *sqlx.DB, c Connection) error
- func (m *Mock) ConnectDB(c Connection, rootDB bool) (*sqlx.DB, error)
- func (m *Mock) LockTable(db *sqlx.DB) bool
- func (m *Mock) UnlockTable(db *sqlx.DB) error
- type Mysql
- func (m *Mysql) CheckDB(db *sqlx.DB, c Connection) error
- func (m *Mysql) CheckTable(db *sqlx.DB, c Connection) error
- func (m *Mysql) CheckUser(db *sqlx.DB, c Connection) error
- func (m *Mysql) ConnectDB(c Connection, rootDB bool) (*sqlx.DB, error)
- func (m *Mysql) LockTable(db *sqlx.DB) bool
- func (m *Mysql) UnlockTable(db *sqlx.DB) error
- type Postgres
- func (p *Postgres) CheckDB(db *sqlx.DB, c Connection) error
- func (p *Postgres) CheckTable(db *sqlx.DB, c Connection) error
- func (p *Postgres) CheckUser(db *sqlx.DB, c Connection) error
- func (p *Postgres) ConnectDB(c Connection, rootDB bool) (*sqlx.DB, error)
- func (p *Postgres) LockTable(db *sqlx.DB) bool
- func (p *Postgres) UnlockTable(db *sqlx.DB) error
- type Sqlite
- func (s *Sqlite) CheckDB(db *sqlx.DB, c Connection) error
- func (s *Sqlite) CheckTable(db *sqlx.DB, c Connection) error
- func (s *Sqlite) CheckUser(db *sqlx.DB, c Connection) error
- func (s *Sqlite) ConnectDB(c Connection, rootDB bool) (*sqlx.DB, error)
- func (s *Sqlite) LockTable(db *sqlx.DB) bool
- func (s *Sqlite) UnlockTable(db *sqlx.DB) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildMigrationMap ¶
func InitializeDB ¶
func InitializeDB(ea EngineAdapter, c Connection) error
func InitializeMigrationTable ¶
func InitializeMigrationTable(ea EngineAdapter, c Connection) (*sqlx.DB, error)
func ProcessFiles ¶
func StartMigration ¶
func StartMigration(c Connection) error
Types ¶
type Connection ¶
type Connection struct { Engine EngineType Host string DB string User string Pwd string AdminUser string AdminPwd string MigrationPath string SkipInitialize bool }
All the migration work is done here
type EngineAdapter ¶
type EngineAdapter interface { ConnectDB(Connection, bool) (*sqlx.DB, error) // the second argument is to tell the function to use admin user/pwd and connect to root DB CheckUser(*sqlx.DB, Connection) error CheckDB(*sqlx.DB, Connection) error CheckTable(*sqlx.DB, Connection) error LockTable(*sqlx.DB) bool UnlockTable(*sqlx.DB) error }
All the migration work is done here
func DetermineEnginerAdapter ¶
func DetermineEnginerAdapter(et EngineType) EngineAdapter
type EngineType ¶
type EngineType string
All the migration work is done here
const ( POSTGRES EngineType = "postgres" MYSQL EngineType = "mysql" SQLITE EngineType = "sqlite" )
type Mock ¶
type Mock struct{}
func (*Mock) CheckTable ¶
func (m *Mock) CheckTable(db *sqlx.DB, c Connection) error
type Mysql ¶
type Mysql struct{}
func (*Mysql) CheckTable ¶
func (m *Mysql) CheckTable(db *sqlx.DB, c Connection) error
type Postgres ¶
type Postgres struct{}
func (*Postgres) CheckTable ¶
func (p *Postgres) CheckTable(db *sqlx.DB, c Connection) error
Click to show internal directories.
Click to hide internal directories.